@@ -288,7 +288,7 @@ |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
291 | - * @param array $strings |
|
291 | + * @param string[] $strings |
|
292 | 292 | * @param string $parameterName |
293 | 293 | * |
294 | 294 | * @throws InvalidArgumentException |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private $crossChecker; |
39 | 39 | |
40 | - public function __construct( EntityLookup $entityLookup, StatementGuidParser $statementGuidParser, CrossChecker $crossChecker ) { |
|
40 | + public function __construct(EntityLookup $entityLookup, StatementGuidParser $statementGuidParser, CrossChecker $crossChecker) { |
|
41 | 41 | $this->entityLookup = $entityLookup; |
42 | 42 | $this->statementGuidParser = $statementGuidParser; |
43 | 43 | $this->crossChecker = $crossChecker; |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return CrossCheckResultList|null |
52 | 52 | */ |
53 | - public function crossCheckEntityById( EntityId $entityId ) { |
|
54 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
53 | + public function crossCheckEntityById(EntityId $entityId) { |
|
54 | + $entity = $this->entityLookup->getEntity($entityId); |
|
55 | 55 | |
56 | - if ( $entity instanceof StatementListProvider ) { |
|
57 | - return $this->crossCheckStatements( $entity->getStatements() ); |
|
56 | + if ($entity instanceof StatementListProvider) { |
|
57 | + return $this->crossCheckStatements($entity->getStatements()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return null; |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return CrossCheckResultList[] |
69 | 69 | */ |
70 | - public function crossCheckEntitiesByIds( array $entityIds ) { |
|
71 | - Assert::parameterElementType( EntityId::class, $entityIds, '$entityIds' ); |
|
70 | + public function crossCheckEntitiesByIds(array $entityIds) { |
|
71 | + Assert::parameterElementType(EntityId::class, $entityIds, '$entityIds'); |
|
72 | 72 | |
73 | 73 | $results = []; |
74 | - foreach ( $entityIds as $entityId ) { |
|
75 | - $results[$entityId->getSerialization()] = $this->crossCheckEntityById( $entityId ); |
|
74 | + foreach ($entityIds as $entityId) { |
|
75 | + $results[$entityId->getSerialization()] = $this->crossCheckEntityById($entityId); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $results; |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return CrossCheckResultList |
87 | 87 | */ |
88 | - public function crossCheckStatements( StatementList $statements ) { |
|
89 | - return $this->crossChecker->crossCheckStatements( $statements, $statements ); |
|
88 | + public function crossCheckStatements(StatementList $statements) { |
|
89 | + return $this->crossChecker->crossCheckStatements($statements, $statements); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | * @return CrossCheckResultList[] |
98 | 98 | * @throws InvalidArgumentException |
99 | 99 | */ |
100 | - public function crossCheckEntities( array $entities ) { |
|
101 | - Assert::parameterElementType( EntityDocument::class, $entities, '$entities' ); |
|
100 | + public function crossCheckEntities(array $entities) { |
|
101 | + Assert::parameterElementType(EntityDocument::class, $entities, '$entities'); |
|
102 | 102 | |
103 | 103 | $results = []; |
104 | - foreach ( $entities as $entity ) { |
|
104 | + foreach ($entities as $entity) { |
|
105 | 105 | $entityId = $entity->getId()->getSerialization(); |
106 | - if ( $entity instanceof StatementListProvider ) { |
|
107 | - $results[$entityId] = $this->crossCheckStatements( $entity->getStatements() ); |
|
106 | + if ($entity instanceof StatementListProvider) { |
|
107 | + $results[$entityId] = $this->crossCheckStatements($entity->getStatements()); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | * @return CrossCheckResultList|null |
121 | 121 | * @throws InvalidArgumentException |
122 | 122 | */ |
123 | - public function crossCheckEntityByIdWithProperties( EntityId $entityId, array $propertyIds ) { |
|
124 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
123 | + public function crossCheckEntityByIdWithProperties(EntityId $entityId, array $propertyIds) { |
|
124 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
125 | 125 | |
126 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
126 | + $entity = $this->entityLookup->getEntity($entityId); |
|
127 | 127 | |
128 | - if ( $entity instanceof StatementListProvider ) { |
|
129 | - return $this->crossCheckStatementsWithProperties( $entity->getStatements(), $propertyIds ); |
|
128 | + if ($entity instanceof StatementListProvider) { |
|
129 | + return $this->crossCheckStatementsWithProperties($entity->getStatements(), $propertyIds); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return null; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * @return CrossCheckResultList[] |
142 | 142 | * @throws InvalidArgumentException |
143 | 143 | */ |
144 | - public function crossCheckEntitiesByIdWithProperties( array $entityIds, array $propertyIds ) { |
|
145 | - Assert::parameterElementType( EntityId::class, $entityIds, '$entityIds' ); |
|
146 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
144 | + public function crossCheckEntitiesByIdWithProperties(array $entityIds, array $propertyIds) { |
|
145 | + Assert::parameterElementType(EntityId::class, $entityIds, '$entityIds'); |
|
146 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
147 | 147 | |
148 | 148 | $results = []; |
149 | - foreach ( $entityIds as $entityId ) { |
|
150 | - $results[$entityId->getSerialization()] = $this->crossCheckEntityByIdWithProperties( $entityId, $propertyIds ); |
|
149 | + foreach ($entityIds as $entityId) { |
|
150 | + $results[$entityId->getSerialization()] = $this->crossCheckEntityByIdWithProperties($entityId, $propertyIds); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $results; |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | * @return CrossCheckResultList |
163 | 163 | * @throws InvalidArgumentException |
164 | 164 | */ |
165 | - public function crossCheckStatementsWithProperties( StatementList $entityStatements, array $propertyIds ) { |
|
166 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
165 | + public function crossCheckStatementsWithProperties(StatementList $entityStatements, array $propertyIds) { |
|
166 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
167 | 167 | |
168 | 168 | $statements = new StatementList(); |
169 | - foreach ( $entityStatements->toArray() as $statement ) { |
|
170 | - if ( in_array( $statement->getPropertyId(), $propertyIds ) ) { |
|
171 | - $statements->addStatement( $statement ); |
|
169 | + foreach ($entityStatements->toArray() as $statement) { |
|
170 | + if (in_array($statement->getPropertyId(), $propertyIds)) { |
|
171 | + $statements->addStatement($statement); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | - return $this->crossChecker->crossCheckStatements( $entityStatements, $statements ); |
|
175 | + return $this->crossChecker->crossCheckStatements($entityStatements, $statements); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | * @return CrossCheckResultList[] |
185 | 185 | * @throws InvalidArgumentException |
186 | 186 | */ |
187 | - public function crossCheckEntitiesWithProperties( array $entities, array $propertyIds ) { |
|
188 | - Assert::parameterElementType( EntityDocument::class, $entities, '$entities' ); |
|
189 | - Assert::parameterElementType( PropertyId::class, $propertyIds, '$propertyIds' ); |
|
187 | + public function crossCheckEntitiesWithProperties(array $entities, array $propertyIds) { |
|
188 | + Assert::parameterElementType(EntityDocument::class, $entities, '$entities'); |
|
189 | + Assert::parameterElementType(PropertyId::class, $propertyIds, '$propertyIds'); |
|
190 | 190 | |
191 | 191 | $results = []; |
192 | - foreach ( $entities as $entity ) { |
|
192 | + foreach ($entities as $entity) { |
|
193 | 193 | $entityId = $entity->getId()->getSerialization(); |
194 | - if ( $entity instanceof StatementListProvider ) { |
|
194 | + if ($entity instanceof StatementListProvider) { |
|
195 | 195 | $results[$entityId] = $this->crossCheckStatementsWithProperties( |
196 | 196 | $entity->getStatements(), |
197 | 197 | $propertyIds |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | * @return CrossCheckResultList |
211 | 211 | * @throws InvalidArgumentException |
212 | 212 | */ |
213 | - public function crossCheckStatementByGuid( $guid ) { |
|
214 | - $this->assertIsString( $guid, '$guid' ); |
|
213 | + public function crossCheckStatementByGuid($guid) { |
|
214 | + $this->assertIsString($guid, '$guid'); |
|
215 | 215 | |
216 | - $resultList = $this->crossCheckStatementsByGuids( [ $guid ] ); |
|
216 | + $resultList = $this->crossCheckStatementsByGuids([$guid]); |
|
217 | 217 | |
218 | - return reset( $resultList ); |
|
218 | + return reset($resultList); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -226,21 +226,21 @@ discard block |
||
226 | 226 | * @return CrossCheckResultList[] |
227 | 227 | * @throws InvalidArgumentException |
228 | 228 | */ |
229 | - public function crossCheckStatementsByGuids( array $guids ) { |
|
230 | - $this->assertIsArrayOfStrings( $guids, '$guids' ); |
|
229 | + public function crossCheckStatementsByGuids(array $guids) { |
|
230 | + $this->assertIsArrayOfStrings($guids, '$guids'); |
|
231 | 231 | |
232 | 232 | $entityIds = []; |
233 | 233 | $groupedStatementGuids = []; |
234 | - foreach ( $guids as $guid ) { |
|
235 | - $serializedEntityId = $this->statementGuidParser->parse( $guid )->getEntityId(); |
|
234 | + foreach ($guids as $guid) { |
|
235 | + $serializedEntityId = $this->statementGuidParser->parse($guid)->getEntityId(); |
|
236 | 236 | $entityIds[$serializedEntityId->getSerialization()] = $serializedEntityId; |
237 | 237 | $groupedStatementGuids[$serializedEntityId->getSerialization()][] = $guid; |
238 | 238 | } |
239 | 239 | |
240 | 240 | $resultLists = []; |
241 | - foreach ( $groupedStatementGuids as $serializedEntityId => $guidsOfEntity ) { |
|
242 | - $entityId = $entityIds[ $serializedEntityId ]; |
|
243 | - $resultLists[ $serializedEntityId ] = $this->crossCheckClaimsOfEntity( $entityId, $guidsOfEntity ); |
|
241 | + foreach ($groupedStatementGuids as $serializedEntityId => $guidsOfEntity) { |
|
242 | + $entityId = $entityIds[$serializedEntityId]; |
|
243 | + $resultLists[$serializedEntityId] = $this->crossCheckClaimsOfEntity($entityId, $guidsOfEntity); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return $resultLists; |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return CrossCheckResultList|null |
254 | 254 | */ |
255 | - private function crossCheckClaimsOfEntity( EntityId $entityId, array $guids ) { |
|
256 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
255 | + private function crossCheckClaimsOfEntity(EntityId $entityId, array $guids) { |
|
256 | + $entity = $this->entityLookup->getEntity($entityId); |
|
257 | 257 | |
258 | - if ( $entity instanceof StatementListProvider ) { |
|
258 | + if ($entity instanceof StatementListProvider) { |
|
259 | 259 | $statements = new StatementList(); |
260 | - foreach ( $entity->getStatements()->toArray() as $statement ) { |
|
261 | - if ( in_array( $statement->getGuid(), $guids ) ) { |
|
262 | - $statements->addStatement( $statement ); |
|
260 | + foreach ($entity->getStatements()->toArray() as $statement) { |
|
261 | + if (in_array($statement->getGuid(), $guids)) { |
|
262 | + $statements->addStatement($statement); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - return $this->crossChecker->crossCheckStatements( $entity->getStatements(), $statements ); |
|
266 | + return $this->crossChecker->crossCheckStatements($entity->getStatements(), $statements); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | return null; |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @throws InvalidArgumentException |
277 | 277 | */ |
278 | - private function assertIsString( $string, $parameterName ) { |
|
279 | - if ( !is_string( $string ) ) { |
|
280 | - throw new InvalidArgumentException( "$parameterName must be string." ); |
|
278 | + private function assertIsString($string, $parameterName) { |
|
279 | + if (!is_string($string)) { |
|
280 | + throw new InvalidArgumentException("$parameterName must be string."); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @throws InvalidArgumentException |
289 | 289 | */ |
290 | - private function assertIsArrayOfStrings( array $strings, $parameterName ) { |
|
291 | - foreach ( $strings as $string ) { |
|
292 | - if ( !is_string( $string ) ) { |
|
293 | - throw new InvalidArgumentException( "Each element of $parameterName must be string." ); |
|
290 | + private function assertIsArrayOfStrings(array $strings, $parameterName) { |
|
291 | + foreach ($strings as $string) { |
|
292 | + if (!is_string($string)) { |
|
293 | + throw new InvalidArgumentException("Each element of $parameterName must be string."); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return bool |
20 | 20 | */ |
21 | - public function canCompare( DataValue $value, DataValue $comparativeValue ); |
|
21 | + public function canCompare(DataValue $value, DataValue $comparativeValue); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Runs the comparison of two DataValues. |
@@ -28,6 +28,6 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string One of the ComparisonResult::STATUS_... constants. |
30 | 30 | */ |
31 | - public function compare( DataValue $value, DataValue $comparativeValue ); |
|
31 | + public function compare(DataValue $value, DataValue $comparativeValue); |
|
32 | 32 | |
33 | 33 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | * @throws InvalidArgumentException |
24 | 24 | * @return string One of the ComparisonResult::STATUS_... constants. |
25 | 25 | */ |
26 | - public function compare( DataValue $value, DataValue $comparativeValue ) { |
|
27 | - if ( !$this->canCompare( $value, $comparativeValue ) ) { |
|
28 | - throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' ); |
|
26 | + public function compare(DataValue $value, DataValue $comparativeValue) { |
|
27 | + if (!$this->canCompare($value, $comparativeValue)) { |
|
28 | + throw new InvalidArgumentException('Given values can not be compared using this comparer.'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | $extLat = $comparativeValue->getLatitude(); |
40 | 40 | $extLong = $comparativeValue->getLongitude(); |
41 | 41 | |
42 | - $diffLat = abs( $locLat - $extLat ); |
|
43 | - $diffLong = abs( $locLong - $extLong ); |
|
44 | - if ( ( $diffLat <= $precision ) && ( $diffLong <= $precision ) ) { |
|
42 | + $diffLat = abs($locLat - $extLat); |
|
43 | + $diffLong = abs($locLong - $extLong); |
|
44 | + if (($diffLat <= $precision) && ($diffLong <= $precision)) { |
|
45 | 45 | return ComparisonResult::STATUS_MATCH; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $daumen = $precision; |
49 | - if ( ( $diffLat <= pi() * $daumen ) && ( $diffLong <= pi() * $daumen ) ) { |
|
49 | + if (($diffLat <= pi() * $daumen) && ($diffLong <= pi() * $daumen)) { |
|
50 | 50 | return ComparisonResult::STATUS_PARTIAL_MATCH; |
51 | 51 | } |
52 | 52 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param DataValue $comparativeValue |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public function canCompare( DataValue $value, DataValue $comparativeValue ) { |
|
63 | + public function canCompare(DataValue $value, DataValue $comparativeValue) { |
|
64 | 64 | return $value instanceof GlobeCoordinateValue && $comparativeValue instanceof GlobeCoordinateValue; |
65 | 65 | } |
66 | 66 |
@@ -15,6 +15,6 @@ |
||
15 | 15 | * |
16 | 16 | * @param DumpMetaInformation $dumpMetaInformation |
17 | 17 | */ |
18 | - public function save( DumpMetaInformation $dumpMetaInformation ); |
|
18 | + public function save(DumpMetaInformation $dumpMetaInformation); |
|
19 | 19 | |
20 | 20 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * @param array &$arr |
21 | 21 | * @param string $tag |
22 | 22 | */ |
23 | - protected function setIndexedTagName( array &$arr, $tag ) { |
|
24 | - ApiResult::setIndexedTagName( $arr, $tag ); |
|
23 | + protected function setIndexedTagName(array &$arr, $tag) { |
|
24 | + ApiResult::setIndexedTagName($arr, $tag); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * @param string $tagName |
34 | 34 | * @param string $idAttribute |
35 | 35 | */ |
36 | - protected function setKeyAttributeName( array &$arr, $tagName, $idAttribute ) { |
|
37 | - ApiResult::setArrayType( $arr, 'kvp', $idAttribute ); |
|
38 | - ApiResult::setIndexedTagName( $arr, $tagName ); |
|
36 | + protected function setKeyAttributeName(array &$arr, $tagName, $idAttribute) { |
|
37 | + ApiResult::setArrayType($arr, 'kvp', $idAttribute); |
|
38 | + ApiResult::setIndexedTagName($arr, $tagName); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -43,11 +43,11 @@ |
||
43 | 43 | * @param int $batchSize |
44 | 44 | * @param bool $quiet |
45 | 45 | */ |
46 | - public function __construct( $externalValuesFilePath, $dumpInformationFilePath, $batchSize, $quiet = false ) { |
|
47 | - Assert::parameterType( 'string', $externalValuesFilePath, '$externalValuesFilePath' ); |
|
48 | - Assert::parameterType( 'string', $dumpInformationFilePath, '$dumpInformationFilePath' ); |
|
49 | - Assert::parameterType( 'integer', $batchSize, '$batchSize' ); |
|
50 | - Assert::parameterType( 'boolean', $quiet, '$quiet' ); |
|
46 | + public function __construct($externalValuesFilePath, $dumpInformationFilePath, $batchSize, $quiet = false) { |
|
47 | + Assert::parameterType('string', $externalValuesFilePath, '$externalValuesFilePath'); |
|
48 | + Assert::parameterType('string', $dumpInformationFilePath, '$dumpInformationFilePath'); |
|
49 | + Assert::parameterType('integer', $batchSize, '$batchSize'); |
|
50 | + Assert::parameterType('boolean', $quiet, '$quiet'); |
|
51 | 51 | |
52 | 52 | $this->externalValuesFilePath = $externalValuesFilePath; |
53 | 53 | $this->dumpInformationFilePath = $dumpInformationFilePath; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | /** |
307 | 307 | * Builds summary from given results |
308 | 308 | * |
309 | - * @param CrossCheckResult[]|CrossCheckResultList $results |
|
309 | + * @param CrossCheckResultList $results |
|
310 | 310 | * |
311 | 311 | * @return string HTML |
312 | 312 | */ |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | - * @param CrossCheckResult[]|CrossCheckResultList $results |
|
399 | + * @param CrossCheckResultList $results |
|
400 | 400 | * |
401 | 401 | * @return string HTML |
402 | 402 | */ |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | OutputFormatValueFormatterFactory $valueFormatterFactory, |
99 | 99 | CrossCheckInteractor $crossCheckInteractor |
100 | 100 | ) { |
101 | - parent::__construct( 'CrossCheck' ); |
|
101 | + parent::__construct('CrossCheck'); |
|
102 | 102 | |
103 | 103 | $this->entityLookup = $entityLookup; |
104 | 104 | $this->entityIdParser = $entityIdParser; |
105 | 105 | |
106 | 106 | $formatterOptions = new FormatterOptions(); |
107 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $this->getLanguage()->getCode() ); |
|
108 | - $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
107 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $this->getLanguage()->getCode()); |
|
108 | + $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
109 | 109 | |
110 | - $labelLookup = new LanguageLabelDescriptionLookup( $termLookup, $this->getLanguage()->getCode() ); |
|
111 | - $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelLookup ); |
|
112 | - $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelLookup ); |
|
110 | + $labelLookup = new LanguageLabelDescriptionLookup($termLookup, $this->getLanguage()->getCode()); |
|
111 | + $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelLookup); |
|
112 | + $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelLookup); |
|
113 | 113 | |
114 | 114 | $this->crossCheckInteractor = $crossCheckInteractor; |
115 | 115 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return string (plain text) |
130 | 130 | */ |
131 | 131 | public function getDescription() { |
132 | - return $this->msg( 'wbqev-crosscheck' )->text(); |
|
132 | + return $this->msg('wbqev-crosscheck')->text(); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -141,55 +141,55 @@ discard block |
||
141 | 141 | * @throws EntityIdParsingException |
142 | 142 | * @throws UnexpectedValueException |
143 | 143 | */ |
144 | - public function execute( $subPage ) { |
|
144 | + public function execute($subPage) { |
|
145 | 145 | $out = $this->getOutput(); |
146 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
147 | - if ( $postRequest ) { |
|
148 | - $out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() ); |
|
146 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
147 | + if ($postRequest) { |
|
148 | + $out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL()); |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - $out->addModules( 'SpecialCrossCheckPage' ); |
|
152 | + $out->addModules('SpecialCrossCheckPage'); |
|
153 | 153 | |
154 | 154 | $this->setHeaders(); |
155 | 155 | |
156 | - $out->addHTML( $this->buildInfoBox() ); |
|
156 | + $out->addHTML($this->buildInfoBox()); |
|
157 | 157 | $this->buildEntityIdForm(); |
158 | 158 | |
159 | - if ( $subPage ) { |
|
160 | - $this->buildResult( $subPage ); |
|
159 | + if ($subPage) { |
|
160 | + $this->buildResult($subPage); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @param string $idSerialization |
166 | 166 | */ |
167 | - private function buildResult( $idSerialization ) { |
|
167 | + private function buildResult($idSerialization) { |
|
168 | 168 | $out = $this->getOutput(); |
169 | 169 | |
170 | 170 | try { |
171 | - $entityId = $this->entityIdParser->parse( $idSerialization ); |
|
172 | - } catch ( EntityIdParsingException $ex ) { |
|
173 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-invalid-entity-id', true ) ); |
|
171 | + $entityId = $this->entityIdParser->parse($idSerialization); |
|
172 | + } catch (EntityIdParsingException $ex) { |
|
173 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-invalid-entity-id', true)); |
|
174 | 174 | return; |
175 | 175 | } |
176 | 176 | |
177 | - $out->addHTML( $this->buildResultHeader( $entityId ) ); |
|
177 | + $out->addHTML($this->buildResultHeader($entityId)); |
|
178 | 178 | |
179 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
180 | - if ( $entity === null ) { |
|
181 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-not-existent-entity', true ) ); |
|
179 | + $entity = $this->entityLookup->getEntity($entityId); |
|
180 | + if ($entity === null) { |
|
181 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-not-existent-entity', true)); |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - $results = $this->getCrossCheckResultsFromEntity( $entity ); |
|
185 | + $results = $this->getCrossCheckResultsFromEntity($entity); |
|
186 | 186 | |
187 | - if ( $results === null || $results->toArray() === [] ) { |
|
188 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-empty-result' ) ); |
|
187 | + if ($results === null || $results->toArray() === []) { |
|
188 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-empty-result')); |
|
189 | 189 | } else { |
190 | 190 | $out->addHTML( |
191 | - $this->buildSummary( $results ) |
|
192 | - . $this->buildResultTable( $results ) |
|
191 | + $this->buildSummary($results) |
|
192 | + . $this->buildResultTable($results) |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return CrossCheckResultList|null |
201 | 201 | */ |
202 | - private function getCrossCheckResultsFromEntity( EntityDocument $entity ) { |
|
203 | - if ( $entity instanceof StatementListProvider ) { |
|
204 | - return $this->crossCheckInteractor->crossCheckStatements( $entity->getStatements() ); |
|
202 | + private function getCrossCheckResultsFromEntity(EntityDocument $entity) { |
|
203 | + if ($entity instanceof StatementListProvider) { |
|
204 | + return $this->crossCheckInteractor->crossCheckStatements($entity->getStatements()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return null; |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | 'name' => 'entityid', |
219 | 219 | 'label-message' => 'wbqev-crosscheck-form-entityid-label', |
220 | 220 | 'cssclass' => 'wbqev-crosscheck-form-entity-id', |
221 | - 'placeholder' => $this->msg( 'wbqev-crosscheck-form-entityid-placeholder' )->escaped() |
|
221 | + 'placeholder' => $this->msg('wbqev-crosscheck-form-entityid-placeholder')->escaped() |
|
222 | 222 | ] |
223 | 223 | ]; |
224 | - $htmlForm = new HTMLForm( $formDescriptor, $this->getContext(), 'wbqev-crosscheck-form' ); |
|
225 | - $htmlForm->setSubmitText( $this->msg( 'wbqev-crosscheck-form-submit-label' )->escaped() ); |
|
226 | - $htmlForm->setSubmitCallback( function() { |
|
224 | + $htmlForm = new HTMLForm($formDescriptor, $this->getContext(), 'wbqev-crosscheck-form'); |
|
225 | + $htmlForm->setSubmitText($this->msg('wbqev-crosscheck-form-submit-label')->escaped()); |
|
226 | + $htmlForm->setSubmitCallback(function() { |
|
227 | 227 | return false; |
228 | 228 | } ); |
229 | - $htmlForm->setMethod( 'post' ); |
|
229 | + $htmlForm->setMethod('post'); |
|
230 | 230 | $htmlForm->show(); |
231 | 231 | } |
232 | 232 | |
@@ -236,18 +236,18 @@ discard block |
||
236 | 236 | * @return string HTML |
237 | 237 | */ |
238 | 238 | private function buildInfoBox() { |
239 | - $externalDbLink = Linker::specialLink( 'ExternalDatabases', 'wbqev-externaldbs' ); |
|
239 | + $externalDbLink = Linker::specialLink('ExternalDatabases', 'wbqev-externaldbs'); |
|
240 | 240 | $infoBox = |
241 | 241 | Html::openElement( |
242 | 242 | 'div', |
243 | - [ 'class' => 'wbqev-infobox' ] |
|
243 | + ['class' => 'wbqev-infobox'] |
|
244 | 244 | ) |
245 | - . $this->msg( 'wbqev-crosscheck-explanation-general' )->parse() |
|
246 | - . sprintf( ' %s.', $externalDbLink ) |
|
247 | - . Html::element( 'br' ) |
|
248 | - . Html::element( 'br' ) |
|
249 | - . $this->msg( 'wbqev-crosscheck-explanation-detail' )->parse() |
|
250 | - . Html::closeElement( 'div' ); |
|
245 | + . $this->msg('wbqev-crosscheck-explanation-general')->parse() |
|
246 | + . sprintf(' %s.', $externalDbLink) |
|
247 | + . Html::element('br') |
|
248 | + . Html::element('br') |
|
249 | + . $this->msg('wbqev-crosscheck-explanation-detail')->parse() |
|
250 | + . Html::closeElement('div'); |
|
251 | 251 | |
252 | 252 | return $infoBox; |
253 | 253 | } |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return string HTML |
264 | 264 | */ |
265 | - private function buildNotice( $messageKey, $error = false ) { |
|
265 | + private function buildNotice($messageKey, $error = false) { |
|
266 | 266 | $cssClasses = 'wbqev-crosscheck-notice'; |
267 | - if ( $error ) { |
|
267 | + if ($error) { |
|
268 | 268 | $cssClasses .= ' wbqev-crosscheck-notice-error'; |
269 | 269 | } |
270 | 270 | |
271 | 271 | return Html::element( |
272 | 272 | 'p', |
273 | - [ 'class' => $cssClasses ], |
|
274 | - $this->msg( $messageKey )->text() |
|
273 | + ['class' => $cssClasses], |
|
274 | + $this->msg($messageKey)->text() |
|
275 | 275 | ); |
276 | 276 | } |
277 | 277 | |
@@ -282,17 +282,17 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return string HTML |
284 | 284 | */ |
285 | - private function buildResultHeader( EntityId $entityId ) { |
|
285 | + private function buildResultHeader(EntityId $entityId) { |
|
286 | 286 | $entityLink = sprintf( |
287 | 287 | '%s (%s)', |
288 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
289 | - htmlspecialchars( $entityId->getSerialization() ) |
|
288 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
289 | + htmlspecialchars($entityId->getSerialization()) |
|
290 | 290 | ); |
291 | 291 | |
292 | 292 | return Html::rawElement( |
293 | 293 | 'h3', |
294 | 294 | [], |
295 | - sprintf( '%s %s', $this->msg( 'wbqev-crosscheck-result-headline' )->escaped(), $entityLink ) |
|
295 | + sprintf('%s %s', $this->msg('wbqev-crosscheck-result-headline')->escaped(), $entityLink) |
|
296 | 296 | ); |
297 | 297 | } |
298 | 298 | |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return string HTML |
305 | 305 | */ |
306 | - private function buildSummary( $results ) { |
|
306 | + private function buildSummary($results) { |
|
307 | 307 | $statuses = []; |
308 | - foreach ( $results as $result ) { |
|
309 | - $status = strtolower( $result->getComparisonResult()->getStatus() ); |
|
310 | - if ( array_key_exists( $status, $statuses ) ) { |
|
308 | + foreach ($results as $result) { |
|
309 | + $status = strtolower($result->getComparisonResult()->getStatus()); |
|
310 | + if (array_key_exists($status, $statuses)) { |
|
311 | 311 | $statuses[$status]++; |
312 | 312 | } else { |
313 | 313 | $statuses[$status] = 1; |
@@ -315,15 +315,15 @@ discard block |
||
315 | 315 | } |
316 | 316 | |
317 | 317 | $statusElements = []; |
318 | - foreach ( $statuses as $status => $count ) { |
|
319 | - if ( $count > 0 ) { |
|
320 | - $statusElements[] = $this->formatStatus( $status ) . ': ' . $count; |
|
318 | + foreach ($statuses as $status => $count) { |
|
319 | + if ($count > 0) { |
|
320 | + $statusElements[] = $this->formatStatus($status).': '.$count; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | $summary = |
324 | - Html::openElement( 'p' ) |
|
325 | - . implode( ', ', $statusElements ) |
|
326 | - . Html::closeElement( 'p' ); |
|
324 | + Html::openElement('p') |
|
325 | + . implode(', ', $statusElements) |
|
326 | + . Html::closeElement('p'); |
|
327 | 327 | |
328 | 328 | return $summary; |
329 | 329 | } |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return string HTML |
339 | 339 | */ |
340 | - private function formatStatus( $status ) { |
|
341 | - $messageKey = 'wbqev-crosscheck-status-' . strtolower( $status ); |
|
340 | + private function formatStatus($status) { |
|
341 | + $messageKey = 'wbqev-crosscheck-status-'.strtolower($status); |
|
342 | 342 | |
343 | 343 | $formattedStatus = |
344 | 344 | Html::element( |
345 | 345 | 'span', |
346 | 346 | [ |
347 | - 'class' => 'wbqev-status wbqev-status-' . htmlspecialchars( $status ) |
|
347 | + 'class' => 'wbqev-status wbqev-status-'.htmlspecialchars($status) |
|
348 | 348 | ], |
349 | - $this->msg( $messageKey )->text() |
|
349 | + $this->msg($messageKey)->text() |
|
350 | 350 | ); |
351 | 351 | |
352 | 352 | return $formattedStatus; |
@@ -363,29 +363,29 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string HTML |
365 | 365 | */ |
366 | - private function formatDataValues( $dataValues, $linking = true, $separator = null ) { |
|
367 | - if ( $dataValues instanceof DataValue ) { |
|
368 | - $dataValues = [ $dataValues ]; |
|
366 | + private function formatDataValues($dataValues, $linking = true, $separator = null) { |
|
367 | + if ($dataValues instanceof DataValue) { |
|
368 | + $dataValues = [$dataValues]; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $formattedDataValues = []; |
372 | - foreach ( $dataValues as $dataValue ) { |
|
373 | - if ( $dataValue instanceof EntityIdValue ) { |
|
374 | - if ( $linking ) { |
|
375 | - $formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
372 | + foreach ($dataValues as $dataValue) { |
|
373 | + if ($dataValue instanceof EntityIdValue) { |
|
374 | + if ($linking) { |
|
375 | + $formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId($dataValue->getEntityId()); |
|
376 | 376 | } else { |
377 | - $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
377 | + $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId()); |
|
378 | 378 | } |
379 | 379 | } else { |
380 | - $formattedDataValues[] = $this->dataValueFormatter->format( $dataValue ); |
|
380 | + $formattedDataValues[] = $this->dataValueFormatter->format($dataValue); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - if ( $separator ) { |
|
385 | - return implode( $separator, $formattedDataValues ); |
|
384 | + if ($separator) { |
|
385 | + return implode($separator, $formattedDataValues); |
|
386 | 386 | } |
387 | 387 | |
388 | - return $this->getLanguage()->commaList( $formattedDataValues ); |
|
388 | + return $this->getLanguage()->commaList($formattedDataValues); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -393,31 +393,31 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return string HTML |
395 | 395 | */ |
396 | - private function buildResultTable( $results ) { |
|
396 | + private function buildResultTable($results) { |
|
397 | 397 | $table = new HtmlTableBuilder( |
398 | 398 | [ |
399 | 399 | new HtmlTableHeaderBuilder( |
400 | - $this->msg( 'wbqev-crosscheck-result-table-header-status' )->escaped(), |
|
400 | + $this->msg('wbqev-crosscheck-result-table-header-status')->escaped(), |
|
401 | 401 | true |
402 | 402 | ), |
403 | 403 | new HtmlTableHeaderBuilder( |
404 | - $this->msg( 'datatypes-type-wikibase-property' )->escaped(), |
|
404 | + $this->msg('datatypes-type-wikibase-property')->escaped(), |
|
405 | 405 | true |
406 | 406 | ), |
407 | 407 | new HtmlTableHeaderBuilder( |
408 | - $this->msg( 'wbqev-crosscheck-result-table-header-local-value' )->escaped() |
|
408 | + $this->msg('wbqev-crosscheck-result-table-header-local-value')->escaped() |
|
409 | 409 | ), |
410 | 410 | new HtmlTableHeaderBuilder( |
411 | - $this->msg( 'wbqev-crosscheck-result-table-header-external-value' )->escaped() |
|
411 | + $this->msg('wbqev-crosscheck-result-table-header-external-value')->escaped() |
|
412 | 412 | ), |
413 | 413 | new HtmlTableHeaderBuilder( |
414 | - $this->msg( 'wbqev-crosscheck-result-table-header-references' )->escaped(), |
|
414 | + $this->msg('wbqev-crosscheck-result-table-header-references')->escaped(), |
|
415 | 415 | true |
416 | 416 | ), |
417 | 417 | new HtmlTableHeaderBuilder( |
418 | 418 | Linker::linkKnown( |
419 | - self::getTitleFor( 'ExternalDatabases' ), |
|
420 | - $this->msg( 'wbqev-crosscheck-result-table-header-external-source' )->escaped() |
|
419 | + self::getTitleFor('ExternalDatabases'), |
|
420 | + $this->msg('wbqev-crosscheck-result-table-header-external-source')->escaped() |
|
421 | 421 | ), |
422 | 422 | true, |
423 | 423 | true |
@@ -426,28 +426,28 @@ discard block |
||
426 | 426 | true |
427 | 427 | ); |
428 | 428 | |
429 | - foreach ( $results as $result ) { |
|
430 | - $status = $this->formatStatus( $result->getComparisonResult()->getStatus() ); |
|
431 | - $propertyId = $this->entityIdLinkFormatter->formatEntityId( $result->getPropertyId() ); |
|
432 | - $localValue = $this->formatDataValues( $result->getComparisonResult()->getLocalValue() ); |
|
429 | + foreach ($results as $result) { |
|
430 | + $status = $this->formatStatus($result->getComparisonResult()->getStatus()); |
|
431 | + $propertyId = $this->entityIdLinkFormatter->formatEntityId($result->getPropertyId()); |
|
432 | + $localValue = $this->formatDataValues($result->getComparisonResult()->getLocalValue()); |
|
433 | 433 | $externalValue = $this->formatDataValues( |
434 | 434 | $result->getComparisonResult()->getExternalValues(), |
435 | 435 | true, |
436 | - Html::element( 'br' ) |
|
436 | + Html::element('br') |
|
437 | 437 | ); |
438 | 438 | $referenceStatus = $this->msg( |
439 | - 'wbqev-crosscheck-status-' . $result->getReferenceResult()->getStatus() |
|
439 | + 'wbqev-crosscheck-status-'.$result->getReferenceResult()->getStatus() |
|
440 | 440 | )->text(); |
441 | - $dataSource = $this->entityIdLinkFormatter->formatEntityId( $result->getDumpMetaInformation()->getSourceItemId() ); |
|
441 | + $dataSource = $this->entityIdLinkFormatter->formatEntityId($result->getDumpMetaInformation()->getSourceItemId()); |
|
442 | 442 | |
443 | 443 | $table->appendRow( |
444 | 444 | [ |
445 | - new HtmlTableCellBuilder( $status, [], true ), |
|
446 | - new HtmlTableCellBuilder( $propertyId, [], true ), |
|
447 | - new HtmlTableCellBuilder( $localValue, [], true ), |
|
448 | - new HtmlTableCellBuilder( $externalValue, [], true ), |
|
449 | - new HtmlTableCellBuilder( $referenceStatus, [] ), |
|
450 | - new HtmlTableCellBuilder( $dataSource, [], true ) |
|
445 | + new HtmlTableCellBuilder($status, [], true), |
|
446 | + new HtmlTableCellBuilder($propertyId, [], true), |
|
447 | + new HtmlTableCellBuilder($localValue, [], true), |
|
448 | + new HtmlTableCellBuilder($externalValue, [], true), |
|
449 | + new HtmlTableCellBuilder($referenceStatus, []), |
|
450 | + new HtmlTableCellBuilder($dataSource, [], true) |
|
451 | 451 | ] |
452 | 452 | ); |
453 | 453 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @return DumpMetaInformation[] |
21 | 21 | * @throws \InvalidArgumentException |
22 | 22 | */ |
23 | - public function getWithIds( array $dumpIds ); |
|
23 | + public function getWithIds(array $dumpIds); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Gets DumpMetaInformation for specific identifier properties from database |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return DumpMetaInformation[] |
32 | 32 | */ |
33 | - public function getWithIdentifierProperties( array $identifierPropertyIds ); |
|
33 | + public function getWithIdentifierProperties(array $identifierPropertyIds); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Gets all DumpMetaInformation from database |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | use WikibaseQuality\ExternalValidation\UpdateExternalData\CsvImportSettings; |
8 | 8 | use WikibaseQuality\ExternalValidation\UpdateExternalData\ExternalDataImporter; |
9 | 9 | |
10 | -$basePath = getenv( 'MW_INSTALL_PATH' ) !== false |
|
11 | - ? getenv( 'MW_INSTALL_PATH' ) |
|
12 | - : __DIR__ . '/../../..'; |
|
13 | -require_once $basePath . '/maintenance/Maintenance.php'; |
|
10 | +$basePath = getenv('MW_INSTALL_PATH') !== false |
|
11 | + ? getenv('MW_INSTALL_PATH') |
|
12 | + : __DIR__.'/../../..'; |
|
13 | +require_once $basePath.'/maintenance/Maintenance.php'; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Maintenance script that evokes updates of wbqev_external_data, wbqev_dump_information, wbqev_identifier_properties |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | public function __construct() { |
26 | 26 | parent::__construct(); |
27 | 27 | |
28 | - $this->addDescription( 'Imports external entities from given CSV files into the local ' |
|
29 | - . 'database. CSV files can be generated using the DumpConverter.' ); |
|
30 | - $this->addOption( 'external-values-file', 'CSV file containing external values for import.', true, true ); |
|
31 | - $this->addOption( 'dump-information-file', 'CSV file containing dump meta information for import.', true, true ); |
|
32 | - $this->setBatchSize( 1000 ); |
|
28 | + $this->addDescription('Imports external entities from given CSV files into the local ' |
|
29 | + . 'database. CSV files can be generated using the DumpConverter.'); |
|
30 | + $this->addOption('external-values-file', 'CSV file containing external values for import.', true, true); |
|
31 | + $this->addOption('dump-information-file', 'CSV file containing dump meta information for import.', true, true); |
|
32 | + $this->setBatchSize(1000); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function execute() { |
36 | 36 | $context = new CsvImportSettings( |
37 | - $this->getOption( 'external-values-file' ), |
|
38 | - $this->getOption( 'dump-information-file' ), |
|
37 | + $this->getOption('external-values-file'), |
|
38 | + $this->getOption('dump-information-file'), |
|
39 | 39 | $this->mBatchSize, |
40 | 40 | $this->isQuiet() |
41 | 41 | ); |