Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
61.11% |
11 / 18 |
|
91.67% |
11 / 12 |
CRAP | |
0.00% |
0 / 1 |
| UserDialect | |
61.11% |
11 / 18 |
|
91.67% |
11 / 12 |
20.47 | |
0.00% |
0 / 1 |
| accept | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| getIdentity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setIdentity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLanguage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setLanguage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSpokenProficiencyLevel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setSpokenProficiencyLevel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLocation | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setLocation | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\WikispeechSpeechDataCollector\Domain; |
| 4 | |
| 5 | /** |
| 6 | * @file |
| 7 | * @ingroup Extensions |
| 8 | * @license GPL-2.0-or-later |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * How well a {@link User} speaks a specific dialect of a {@link Language} |
| 13 | * and the geographic area that best describes the accent or dialect. |
| 14 | * |
| 15 | * @since 0.1.0 |
| 16 | */ |
| 17 | class UserDialect implements Persistent { |
| 18 | /** @var string|null 128 bits UUID */ |
| 19 | private $identity; |
| 20 | |
| 21 | /** |
| 22 | * A user can be associated with multiple dialects at different levels. |
| 23 | * |
| 24 | * @var string|null 128 bits UUID |
| 25 | * @see User::$identity |
| 26 | */ |
| 27 | private $user; |
| 28 | |
| 29 | /** |
| 30 | * @var string|null 128 bits UUID |
| 31 | * @see Language::$identity |
| 32 | */ |
| 33 | private $language; |
| 34 | |
| 35 | /** |
| 36 | * @var int|null How well the user speaks this language |
| 37 | * @see LanguageProficiencyLevel |
| 38 | */ |
| 39 | private $spokenProficiencyLevel; |
| 40 | |
| 41 | /** |
| 42 | * GeoJSON as string value. |
| 43 | * |
| 44 | * Geometry that best fit the area that represents the spoken dialect. |
| 45 | * |
| 46 | * A German speaking Swedish with a broken accent |
| 47 | * might best be represented by an envelope over a large part of Germany. |
| 48 | * |
| 49 | * A native Swedish person living in Stockholm for the last 40 years but still |
| 50 | * speak with a Gothenburg dialect might best be described with an envelope |
| 51 | * covering a large area that also include Gothenburg. |
| 52 | * |
| 53 | * A person living in an suburb that is known to have a dialect that differs |
| 54 | * from the rest of the surrounding area, perhaps due to socioeconomic factors |
| 55 | * towards one way or the other, it might be best to pinpoint that area rather |
| 56 | * than defining a geometry that spans the greater city area. |
| 57 | * |
| 58 | * @todo How do we enable GIS queries in the database? |
| 59 | * @var string|null |
| 60 | */ |
| 61 | private $location; |
| 62 | |
| 63 | // visitor |
| 64 | |
| 65 | /** |
| 66 | * @param PersistentVisitor $visitor |
| 67 | * @return mixed|null |
| 68 | */ |
| 69 | public function accept( PersistentVisitor $visitor ) { |
| 70 | return $visitor->visitUserDialect( $this ); |
| 71 | } |
| 72 | |
| 73 | public function __toString(): string { |
| 74 | return '[ ' . |
| 75 | 'identity => "' . $this->getIdentity() . '", ' . |
| 76 | 'user => "' . $this->getUser() . '", ' . |
| 77 | 'language => "' . $this->getLanguage() . '", ' . |
| 78 | 'spokenProficiencyLevel => "' . $this->getSpokenProficiencyLevel() . '", ' . |
| 79 | 'location => "' . $this->getLocation() . '" ' . |
| 80 | ']'; |
| 81 | } |
| 82 | |
| 83 | // getters and setters |
| 84 | |
| 85 | /** |
| 86 | * @see UserDialect::$identity |
| 87 | * @return string|null |
| 88 | */ |
| 89 | public function getIdentity(): ?string { |
| 90 | return $this->identity; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @see UserDialect::$identity |
| 95 | * @param string|null $identity |
| 96 | */ |
| 97 | public function setIdentity( $identity ): void { |
| 98 | $this->identity = $identity; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @see UserDialect::$user |
| 103 | * @return string|null |
| 104 | */ |
| 105 | public function getUser(): ?string { |
| 106 | return $this->user; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * @see UserDialect::$user |
| 111 | * @param string|null $user |
| 112 | */ |
| 113 | public function setUser( ?string $user ): void { |
| 114 | $this->user = $user; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @see UserDialect::$language |
| 119 | * @return string|null |
| 120 | */ |
| 121 | public function getLanguage(): ?string { |
| 122 | return $this->language; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @see UserDialect::$language |
| 127 | * @param string|null $language |
| 128 | */ |
| 129 | public function setLanguage( ?string $language ): void { |
| 130 | $this->language = $language; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @see UserDialect::$spokenProficiencyLevel |
| 135 | * @return int|null |
| 136 | */ |
| 137 | public function getSpokenProficiencyLevel(): ?int { |
| 138 | return $this->spokenProficiencyLevel; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * @see UserDialect::$spokenProficiencyLevel |
| 143 | * @param int|null $spokenProficiencyLevel |
| 144 | */ |
| 145 | public function setSpokenProficiencyLevel( ?int $spokenProficiencyLevel ): void { |
| 146 | $this->spokenProficiencyLevel = $spokenProficiencyLevel; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * @see UserDialect::$location |
| 151 | * @return string|null |
| 152 | */ |
| 153 | public function getLocation(): ?string { |
| 154 | return $this->location; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * @see UserDialect::$location |
| 159 | * @param string|null $location |
| 160 | */ |
| 161 | public function setLocation( ?string $location ): void { |
| 162 | $this->location = $location; |
| 163 | } |
| 164 | } |