Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
58.33% |
7 / 12 |
|
87.50% |
7 / 8 |
CRAP | |
0.00% |
0 / 1 |
User | |
58.33% |
7 / 12 |
|
87.50% |
7 / 8 |
12.63 | |
0.00% |
0 / 1 |
accept | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__toString | |
0.00% |
0 / 5 |
|
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 | |||
getMediaWikiUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMediaWikiUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getYearBorn | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setYearBorn | |
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 | * An augmentation of the MediaWiki {@link \User}. Allows for easily adding new |
13 | * information that make sense in this extension but might not be accepted in |
14 | * the MediaWiki core. Also, by keeping track of users with our own identity |
15 | * we're not pointing to the MediaWiki user identity as relations from other |
16 | * tables. This allows us to export data from this system and while keeping |
17 | * users completely anonymous. |
18 | * |
19 | * @since 0.1.0 |
20 | */ |
21 | class User implements Persistent { |
22 | /** @var string|null 128 bits UUID */ |
23 | private $identity; |
24 | |
25 | /** |
26 | * @var int|null {@link \User::getId()} |
27 | */ |
28 | private $mediaWikiUser; |
29 | |
30 | /** |
31 | * @var int|null Year born, Gregorian calendar. |
32 | * Used to evaluate age of user in a recorded voice. |
33 | * @todo Consider if we should store age of recoded user in each recording as an index. |
34 | */ |
35 | private $yearBorn; |
36 | |
37 | // visitor |
38 | |
39 | /** |
40 | * @param PersistentVisitor $visitor |
41 | * @return mixed|null |
42 | */ |
43 | public function accept( PersistentVisitor $visitor ) { |
44 | return $visitor->visitUser( $this ); |
45 | } |
46 | |
47 | public function __toString(): string { |
48 | return '[ ' . |
49 | 'identity => "' . $this->getIdentity() . '", ' . |
50 | 'wikimediaUser => "' . $this->getMediaWikiUser() . '", ' . |
51 | 'yearBorn => "' . $this->getYearBorn() . '" ' . |
52 | ']'; |
53 | } |
54 | |
55 | // getters and setters |
56 | |
57 | /** |
58 | * @see User::$identity |
59 | * @return string|null |
60 | */ |
61 | public function getIdentity(): ?string { |
62 | return $this->identity; |
63 | } |
64 | |
65 | /** |
66 | * @see User::$identity |
67 | * @param string|null $identity |
68 | */ |
69 | public function setIdentity( $identity ): void { |
70 | $this->identity = $identity; |
71 | } |
72 | |
73 | /** |
74 | * @see User::$mediaWikiUser |
75 | * @return int|null |
76 | */ |
77 | public function getMediaWikiUser(): ?int { |
78 | return $this->mediaWikiUser; |
79 | } |
80 | |
81 | /** |
82 | * @see User::$mediaWikiUser |
83 | * @param int|null $mediaWikiUser |
84 | */ |
85 | public function setMediaWikiUser( ?int $mediaWikiUser ): void { |
86 | $this->mediaWikiUser = $mediaWikiUser; |
87 | } |
88 | |
89 | /** |
90 | * @see User::$yearBorn |
91 | * @return int|null |
92 | */ |
93 | public function getYearBorn(): ?int { |
94 | return $this->yearBorn; |
95 | } |
96 | |
97 | /** |
98 | * @see User::$yearBorn |
99 | * @param int|null $yearBorn |
100 | */ |
101 | public function setYearBorn( ?int $yearBorn ): void { |
102 | $this->yearBorn = $yearBorn; |
103 | } |
104 | } |