Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
61.90% |
13 / 21 |
|
92.86% |
13 / 14 |
CRAP | |
0.00% |
0 / 1 |
Recording | |
61.90% |
13 / 21 |
|
92.86% |
13 / 14 |
24.84 | |
0.00% |
0 / 1 |
accept | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__toString | |
0.00% |
0 / 8 |
|
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 | |||
getRecorded | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRecorded | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getVoiceOf | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setVoiceOf | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSpokenDialect | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSpokenDialect | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getManuscriptPrompt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setManuscriptPrompt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAudioFileWikiPageIdentity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAudioFileWikiPageIdentity | |
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 | use MWTimestamp; |
12 | |
13 | /** |
14 | * The audio representation of a {@link ManuscriptPrompt} |
15 | * recorded by a given {@link User} in a given {@link UserDialect}. |
16 | * |
17 | * @todo We could (should?) add indices in this object to avoid expensive |
18 | * joining of tables and database end calculations: |
19 | * * Age of user at recording (Recording->recorded - Recording->voiceOf->yearBorn) |
20 | * * Recorded language (Recording->manuscriptPrompt->manuscript->language) |
21 | * * etc |
22 | * I.e. use denormalized information in the database, not database indices. |
23 | * |
24 | * @since 0.1.0 |
25 | */ |
26 | class Recording implements Persistent { |
27 | /** @var string|null 128 bits UUID */ |
28 | private $identity; |
29 | |
30 | /** @var MWTimestamp|null */ |
31 | private $recorded; |
32 | |
33 | /** |
34 | * @var string|null 128 bits UUID |
35 | * @see User::$identity |
36 | */ |
37 | private $voiceOf; |
38 | |
39 | /** |
40 | * @var string|null 128 bits UUID |
41 | * @see UserDialect::$identity |
42 | */ |
43 | private $spokenDialect; |
44 | |
45 | /** |
46 | * @var string|null 128 bits UUID |
47 | * @see ManuscriptPrompt::$identity |
48 | */ |
49 | private $manuscriptPrompt; |
50 | |
51 | /** |
52 | * @var int|null |
53 | */ |
54 | private $audioFileWikiPageIdentity; |
55 | |
56 | // visitor |
57 | |
58 | /** |
59 | * @param PersistentVisitor $visitor |
60 | * @return mixed|null |
61 | */ |
62 | public function accept( PersistentVisitor $visitor ) { |
63 | return $visitor->visitRecording( $this ); |
64 | } |
65 | |
66 | public function __toString(): string { |
67 | return '[ ' . |
68 | 'identity => "' . $this->getIdentity() . '", ' . |
69 | 'recorded => "' . $this->getRecorded() . '", ' . |
70 | 'voiceOf => "' . $this->getVoiceOf() . '", ' . |
71 | 'spokenDialect => "' . $this->getSpokenDialect() . '", ' . |
72 | 'manuscriptPrompt => "' . $this->getManuscriptPrompt() . '", ' . |
73 | 'audioFileWikiPageIdentity => "' . $this->getAudioFileWikiPageIdentity() . '" ' . |
74 | ']'; |
75 | } |
76 | |
77 | // getters and setters |
78 | |
79 | /** |
80 | * @see Recording::$identity |
81 | * @return string|null |
82 | */ |
83 | public function getIdentity(): ?string { |
84 | return $this->identity; |
85 | } |
86 | |
87 | /** |
88 | * @see Recording::$identity |
89 | * @param string|null $identity |
90 | */ |
91 | public function setIdentity( $identity ): void { |
92 | $this->identity = $identity; |
93 | } |
94 | |
95 | /** |
96 | * @see Recording::$recorded |
97 | * @return MWTimestamp|null |
98 | */ |
99 | public function getRecorded(): ?MWTimestamp { |
100 | return $this->recorded; |
101 | } |
102 | |
103 | /** |
104 | * @see Recording::$recorded |
105 | * @param MWTimestamp|null $recorded |
106 | */ |
107 | public function setRecorded( ?MWTimestamp $recorded ): void { |
108 | $this->recorded = $recorded; |
109 | } |
110 | |
111 | /** |
112 | * @see Recording::$voiceOf |
113 | * @return string|null |
114 | */ |
115 | public function getVoiceOf(): ?string { |
116 | return $this->voiceOf; |
117 | } |
118 | |
119 | /** |
120 | * @see Recording::$voiceOf |
121 | * @param string|null $voiceOf |
122 | */ |
123 | public function setVoiceOf( ?string $voiceOf ): void { |
124 | $this->voiceOf = $voiceOf; |
125 | } |
126 | |
127 | /** |
128 | * @see Recording::$spokenDialect |
129 | * @return string|null |
130 | */ |
131 | public function getSpokenDialect(): ?string { |
132 | return $this->spokenDialect; |
133 | } |
134 | |
135 | /** |
136 | * @see Recording::$spokenDialect |
137 | * @param string|null $spokenDialect |
138 | */ |
139 | public function setSpokenDialect( ?string $spokenDialect ): void { |
140 | $this->spokenDialect = $spokenDialect; |
141 | } |
142 | |
143 | /** |
144 | * @see Recording::$manuscriptPrompt |
145 | * @return string|null |
146 | */ |
147 | public function getManuscriptPrompt(): ?string { |
148 | return $this->manuscriptPrompt; |
149 | } |
150 | |
151 | /** |
152 | * @see Recording::$manuscriptPrompt |
153 | * @param string|null $manuscriptPrompt |
154 | */ |
155 | public function setManuscriptPrompt( ?string $manuscriptPrompt ): void { |
156 | $this->manuscriptPrompt = $manuscriptPrompt; |
157 | } |
158 | |
159 | /** |
160 | * @see Recording::$audioFileWikiPageIdentity |
161 | * @return int|null |
162 | */ |
163 | public function getAudioFileWikiPageIdentity(): ?int { |
164 | return $this->audioFileWikiPageIdentity; |
165 | } |
166 | |
167 | /** |
168 | * @see Recording::$audioFileWikiPageIdentity |
169 | * @param int|null $audioFileWikiPageIdentity |
170 | */ |
171 | public function setAudioFileWikiPageIdentity( ?int $audioFileWikiPageIdentity ): void { |
172 | $this->audioFileWikiPageIdentity = $audioFileWikiPageIdentity; |
173 | } |
174 | |
175 | } |