@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return CheckResult |
57 | 57 | */ |
58 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
59 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
60 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
58 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
59 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
60 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $propertyId = $context->getSnak()->getPropertyId(); |
@@ -65,22 +65,22 @@ discard block |
||
65 | 65 | $parameters = []; |
66 | 66 | |
67 | 67 | $propertyCount = $this->valueCountCheckerHelper->getPropertyCount( |
68 | - $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ), |
|
68 | + $context->getSnakGroup(Context::GROUP_NON_DEPRECATED), |
|
69 | 69 | $propertyId |
70 | 70 | ); |
71 | 71 | |
72 | - if ( $propertyCount <= 1 ) { |
|
73 | - $message = new ViolationMessage( 'wbqc-violation-message-multi-value' ); |
|
72 | + if ($propertyCount <= 1) { |
|
73 | + $message = new ViolationMessage('wbqc-violation-message-multi-value'); |
|
74 | 74 | $status = CheckResult::STATUS_VIOLATION; |
75 | 75 | } else { |
76 | 76 | $message = null; |
77 | 77 | $status = CheckResult::STATUS_COMPLIANCE; |
78 | 78 | } |
79 | 79 | |
80 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
80 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
81 | 81 | } |
82 | 82 | |
83 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
83 | + public function checkConstraintParameters(Constraint $constraint) { |
|
84 | 84 | // no parameters |
85 | 85 | return []; |
86 | 86 | } |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @throws ConstraintParameterException |
85 | 85 | * @return array [ DataValue|null $min, DataValue|null $max, PropertyId $property, array $parameters ] |
86 | 86 | */ |
87 | - private function parseConstraintParameters( Constraint $constraint ) { |
|
88 | - list( $min, $max ) = $this->constraintParameterParser->parseQuantityRangeParameter( |
|
87 | + private function parseConstraintParameters(Constraint $constraint) { |
|
88 | + list($min, $max) = $this->constraintParameterParser->parseQuantityRangeParameter( |
|
89 | 89 | $constraint->getConstraintParameters(), |
90 | 90 | $constraint->getConstraintTypeItemId() |
91 | 91 | ); |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | $constraint->getConstraintTypeItemId() |
95 | 95 | ); |
96 | 96 | |
97 | - if ( $min !== null ) { |
|
98 | - $parameters['minimum_quantity'] = [ $min ]; |
|
97 | + if ($min !== null) { |
|
98 | + $parameters['minimum_quantity'] = [$min]; |
|
99 | 99 | } |
100 | - if ( $max !== null ) { |
|
101 | - $parameters['maximum_quantity'] = [ $max ]; |
|
100 | + if ($max !== null) { |
|
101 | + $parameters['maximum_quantity'] = [$max]; |
|
102 | 102 | } |
103 | - $parameters['property'] = [ $property ]; |
|
103 | + $parameters['property'] = [$property]; |
|
104 | 104 | |
105 | - return [ $min, $max, $property, $parameters ]; |
|
105 | + return [$min, $max, $property, $parameters]; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return bool |
114 | 114 | */ |
115 | - private function rangeInYears( $min, $max ) { |
|
116 | - $yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' ); |
|
115 | + private function rangeInYears($min, $max) { |
|
116 | + $yearUnit = $this->config->get('WBQualityConstraintsYearUnit'); |
|
117 | 117 | |
118 | - if ( $min !== null && $min->getUnit() === $yearUnit ) { |
|
118 | + if ($min !== null && $min->getUnit() === $yearUnit) { |
|
119 | 119 | return true; |
120 | 120 | } |
121 | - if ( $max !== null && $max->getUnit() === $yearUnit ) { |
|
121 | + if ($max !== null && $max->getUnit() === $yearUnit) { |
|
122 | 122 | return true; |
123 | 123 | } |
124 | 124 | |
@@ -134,59 +134,58 @@ discard block |
||
134 | 134 | * @throws ConstraintParameterException |
135 | 135 | * @return CheckResult |
136 | 136 | */ |
137 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
138 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
139 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
137 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
138 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
139 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | $parameters = []; |
143 | 143 | |
144 | 144 | $snak = $context->getSnak(); |
145 | 145 | |
146 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
146 | + if (!$snak instanceof PropertyValueSnak) { |
|
147 | 147 | // nothing to check |
148 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
148 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | $minuend = $snak->getDataValue(); |
152 | 152 | |
153 | 153 | /** @var PropertyId $property */ |
154 | - list( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint ); |
|
154 | + list($min, $max, $property, $parameters) = $this->parseConstraintParameters($constraint); |
|
155 | 155 | |
156 | 156 | // checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property) |
157 | - foreach ( $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ) as $otherSnak ) { |
|
157 | + foreach ($context->getSnakGroup(Context::GROUP_NON_DEPRECATED) as $otherSnak) { |
|
158 | 158 | if ( |
159 | - !$property->equals( $otherSnak->getPropertyId() ) || |
|
159 | + !$property->equals($otherSnak->getPropertyId()) || |
|
160 | 160 | !$otherSnak instanceof PropertyValueSnak |
161 | 161 | ) { |
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $subtrahend = $otherSnak->getDataValue(); |
166 | - if ( $subtrahend->getType() === $minuend->getType() ) { |
|
167 | - $diff = $this->rangeInYears( $min, $max ) && $minuend->getType() === 'time' ? |
|
168 | - $this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) : |
|
169 | - $this->rangeCheckerHelper->getDifference( $minuend, $subtrahend ); |
|
166 | + if ($subtrahend->getType() === $minuend->getType()) { |
|
167 | + $diff = $this->rangeInYears($min, $max) && $minuend->getType() === 'time' ? |
|
168 | + $this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend); |
|
170 | 169 | |
171 | - if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 || |
|
172 | - $this->rangeCheckerHelper->getComparison( $diff, $max ) > 0 |
|
170 | + if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 || |
|
171 | + $this->rangeCheckerHelper->getComparison($diff, $max) > 0 |
|
173 | 172 | ) { |
174 | 173 | // at least one of $min, $max is set at this point, otherwise there could be no violation |
175 | - $openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen'; |
|
174 | + $openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen'; |
|
176 | 175 | // possible message keys: |
177 | 176 | // wbqc-violation-message-diff-within-range |
178 | 177 | // wbqc-violation-message-diff-within-range-leftopen |
179 | 178 | // wbqc-violation-message-diff-within-range-rightopen |
180 | - $message = ( new ViolationMessage( "wbqc-violation-message-diff-within-range$openness" ) ) |
|
181 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
182 | - ->withDataValue( $minuend, Role::OBJECT ) |
|
183 | - ->withEntityId( $otherSnak->getPropertyId(), Role::PREDICATE ) |
|
184 | - ->withDataValue( $subtrahend, Role::OBJECT ); |
|
185 | - if ( $min !== null ) { |
|
186 | - $message = $message->withDataValue( $min, Role::OBJECT ); |
|
179 | + $message = (new ViolationMessage("wbqc-violation-message-diff-within-range$openness")) |
|
180 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
181 | + ->withDataValue($minuend, Role::OBJECT) |
|
182 | + ->withEntityId($otherSnak->getPropertyId(), Role::PREDICATE) |
|
183 | + ->withDataValue($subtrahend, Role::OBJECT); |
|
184 | + if ($min !== null) { |
|
185 | + $message = $message->withDataValue($min, Role::OBJECT); |
|
187 | 186 | } |
188 | - if ( $max !== null ) { |
|
189 | - $message = $message->withDataValue( $max, Role::OBJECT ); |
|
187 | + if ($max !== null) { |
|
188 | + $message = $message->withDataValue($max, Role::OBJECT); |
|
190 | 189 | } |
191 | 190 | $status = CheckResult::STATUS_VIOLATION; |
192 | 191 | } else { |
@@ -194,17 +193,17 @@ discard block |
||
194 | 193 | $status = CheckResult::STATUS_COMPLIANCE; |
195 | 194 | } |
196 | 195 | } else { |
197 | - $message = new ViolationMessage( 'wbqc-violation-message-diff-within-range-must-have-equal-types' ); |
|
196 | + $message = new ViolationMessage('wbqc-violation-message-diff-within-range-must-have-equal-types'); |
|
198 | 197 | $status = CheckResult::STATUS_VIOLATION; |
199 | 198 | } |
200 | 199 | |
201 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
200 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
202 | 201 | } |
203 | 202 | |
204 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
203 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
205 | 204 | } |
206 | 205 | |
207 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
206 | + public function checkConstraintParameters(Constraint $constraint) { |
|
208 | 207 | $constraintParameters = $constraint->getConstraintParameters(); |
209 | 208 | $exceptions = []; |
210 | 209 | try { |
@@ -212,12 +211,12 @@ discard block |
||
212 | 211 | $constraintParameters, |
213 | 212 | $constraint->getConstraintTypeItemId() |
214 | 213 | ); |
215 | - } catch ( ConstraintParameterException $e ) { |
|
214 | + } catch (ConstraintParameterException $e) { |
|
216 | 215 | $exceptions[] = $e; |
217 | 216 | } |
218 | 217 | try { |
219 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
220 | - } catch ( ConstraintParameterException $e ) { |
|
218 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
219 | + } catch (ConstraintParameterException $e) { |
|
221 | 220 | $exceptions[] = $e; |
222 | 221 | } |
223 | 222 | return $exceptions; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | public static function getDefaultInstance() { |
154 | 154 | static $instance = null; |
155 | 155 | |
156 | - if ( $instance === null ) { |
|
156 | + if ($instance === null) { |
|
157 | 157 | $wikibaseRepo = WikibaseRepo::getDefaultInstance(); |
158 | 158 | $entityIdFormatter = $wikibaseRepo->getEntityIdHtmlLinkFormatterFactory()->getEntityIdFormatter( |
159 | 159 | $wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory()->newLabelDescriptionLookup( |
@@ -234,21 +234,21 @@ discard block |
||
234 | 234 | * @return DelegatingConstraintChecker |
235 | 235 | */ |
236 | 236 | public function getConstraintChecker() { |
237 | - if ( $this->delegatingConstraintChecker === null ) { |
|
237 | + if ($this->delegatingConstraintChecker === null) { |
|
238 | 238 | $this->delegatingConstraintChecker = new DelegatingConstraintChecker( |
239 | 239 | $this->lookup, |
240 | 240 | $this->getConstraintCheckerMap(), |
241 | - new CachingConstraintLookup( $this->getConstraintRepository() ), |
|
241 | + new CachingConstraintLookup($this->getConstraintRepository()), |
|
242 | 242 | $this->constraintParameterParser, |
243 | 243 | $this->statementGuidParser, |
244 | 244 | new LoggingHelper( |
245 | 245 | $this->dataFactory, |
246 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
246 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
247 | 247 | $this->config |
248 | 248 | ), |
249 | - $this->config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
250 | - $this->config->get( 'WBQualityConstraintsCheckReferences' ), |
|
251 | - $this->config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
249 | + $this->config->get('WBQualityConstraintsCheckQualifiers'), |
|
250 | + $this->config->get('WBQualityConstraintsCheckReferences'), |
|
251 | + $this->config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
252 | 252 | ); |
253 | 253 | } |
254 | 254 | |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | * @return ConstraintChecker[] |
260 | 260 | */ |
261 | 261 | private function getConstraintCheckerMap() { |
262 | - if ( $this->constraintCheckerMap === null ) { |
|
262 | + if ($this->constraintCheckerMap === null) { |
|
263 | 263 | $connectionCheckerHelper = new ConnectionCheckerHelper(); |
264 | - $rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter ); |
|
265 | - if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) { |
|
264 | + $rangeCheckerHelper = new RangeCheckerHelper($this->config, $this->unitConverter); |
|
265 | + if ($this->config->get('WBQualityConstraintsSparqlEndpoint') !== '') { |
|
266 | 266 | $sparqlHelper = new SparqlHelper( |
267 | 267 | $this->config, |
268 | 268 | $this->rdfVocabulary, |
@@ -285,74 +285,74 @@ discard block |
||
285 | 285 | ); |
286 | 286 | |
287 | 287 | $this->constraintCheckerMap = [ |
288 | - $this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
288 | + $this->config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
289 | 289 | => new ConflictsWithChecker( |
290 | 290 | $this->lookup, |
291 | 291 | $this->constraintParameterParser, |
292 | 292 | $connectionCheckerHelper, |
293 | 293 | $this->constraintParameterRenderer |
294 | 294 | ), |
295 | - $this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
295 | + $this->config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
296 | 296 | => new ItemChecker( |
297 | 297 | $this->lookup, |
298 | 298 | $this->constraintParameterParser, |
299 | 299 | $connectionCheckerHelper, |
300 | 300 | $this->constraintParameterRenderer |
301 | 301 | ), |
302 | - $this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
302 | + $this->config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
303 | 303 | => new TargetRequiredClaimChecker( |
304 | 304 | $this->lookup, |
305 | 305 | $this->constraintParameterParser, |
306 | 306 | $connectionCheckerHelper, |
307 | 307 | $this->constraintParameterRenderer |
308 | 308 | ), |
309 | - $this->config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
309 | + $this->config->get('WBQualityConstraintsSymmetricConstraintId') |
|
310 | 310 | => new SymmetricChecker( |
311 | 311 | $this->lookup, |
312 | 312 | $connectionCheckerHelper, |
313 | 313 | $this->constraintParameterRenderer |
314 | 314 | ), |
315 | - $this->config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
315 | + $this->config->get('WBQualityConstraintsInverseConstraintId') |
|
316 | 316 | => new InverseChecker( |
317 | 317 | $this->lookup, |
318 | 318 | $this->constraintParameterParser, |
319 | 319 | $connectionCheckerHelper, |
320 | 320 | $this->constraintParameterRenderer |
321 | 321 | ), |
322 | - $this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
322 | + $this->config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
323 | 323 | => new QualifierChecker(), |
324 | - $this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
324 | + $this->config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
325 | 325 | => new QualifiersChecker( |
326 | 326 | $this->constraintParameterParser, |
327 | 327 | $this->constraintParameterRenderer |
328 | 328 | ), |
329 | - $this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
329 | + $this->config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
330 | 330 | => new MandatoryQualifiersChecker( |
331 | 331 | $this->constraintParameterParser, |
332 | 332 | $this->constraintParameterRenderer |
333 | 333 | ), |
334 | - $this->config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
334 | + $this->config->get('WBQualityConstraintsRangeConstraintId') |
|
335 | 335 | => new RangeChecker( |
336 | 336 | $this->propertyDataTypeLookup, |
337 | 337 | $this->constraintParameterParser, |
338 | 338 | $rangeCheckerHelper, |
339 | 339 | $this->constraintParameterRenderer |
340 | 340 | ), |
341 | - $this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
341 | + $this->config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
342 | 342 | => new DiffWithinRangeChecker( |
343 | 343 | $this->constraintParameterParser, |
344 | 344 | $rangeCheckerHelper, |
345 | 345 | $this->constraintParameterRenderer, |
346 | 346 | $this->config |
347 | 347 | ), |
348 | - $this->config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
348 | + $this->config->get('WBQualityConstraintsTypeConstraintId') |
|
349 | 349 | => new TypeChecker( |
350 | 350 | $this->lookup, |
351 | 351 | $this->constraintParameterParser, |
352 | 352 | $typeCheckerHelper, |
353 | 353 | $this->config |
354 | 354 | ), |
355 | - $this->config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
355 | + $this->config->get('WBQualityConstraintsValueTypeConstraintId') |
|
356 | 356 | => new ValueTypeChecker( |
357 | 357 | $this->lookup, |
358 | 358 | $this->constraintParameterParser, |
@@ -360,45 +360,45 @@ discard block |
||
360 | 360 | $typeCheckerHelper, |
361 | 361 | $this->config |
362 | 362 | ), |
363 | - $this->config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
363 | + $this->config->get('WBQualityConstraintsSingleValueConstraintId') |
|
364 | 364 | => new SingleValueChecker(), |
365 | - $this->config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
365 | + $this->config->get('WBQualityConstraintsMultiValueConstraintId') |
|
366 | 366 | => new MultiValueChecker(), |
367 | - $this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
367 | + $this->config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
368 | 368 | => new UniqueValueChecker( |
369 | 369 | $this->constraintParameterRenderer, |
370 | 370 | $sparqlHelper |
371 | 371 | ), |
372 | - $this->config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
372 | + $this->config->get('WBQualityConstraintsFormatConstraintId') |
|
373 | 373 | => new FormatChecker( |
374 | 374 | $this->constraintParameterParser, |
375 | 375 | $this->constraintParameterRenderer, |
376 | 376 | $this->config, |
377 | 377 | $sparqlHelper |
378 | 378 | ), |
379 | - $this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
379 | + $this->config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
380 | 380 | => new CommonsLinkChecker( |
381 | 381 | $this->constraintParameterParser, |
382 | 382 | $this->constraintParameterRenderer, |
383 | 383 | $this->titleParser |
384 | 384 | ), |
385 | - $this->config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
385 | + $this->config->get('WBQualityConstraintsOneOfConstraintId') |
|
386 | 386 | => new OneOfChecker( |
387 | 387 | $this->constraintParameterParser, |
388 | 388 | $this->constraintParameterRenderer |
389 | 389 | ), |
390 | - $this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
390 | + $this->config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
391 | 391 | => new ValueOnlyChecker(), |
392 | - $this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
392 | + $this->config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
393 | 393 | => new ReferenceChecker(), |
394 | - $this->config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
394 | + $this->config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
395 | 395 | => new NoBoundsChecker(), |
396 | - $this->config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
396 | + $this->config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
397 | 397 | => new AllowedUnitsChecker( |
398 | 398 | $this->constraintParameterParser, |
399 | 399 | $this->unitConverter |
400 | 400 | ), |
401 | - $this->config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
401 | + $this->config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
402 | 402 | => new SingleBestValueChecker(), |
403 | 403 | ]; |
404 | 404 | } |
@@ -410,26 +410,26 @@ discard block |
||
410 | 410 | * @return array[] |
411 | 411 | */ |
412 | 412 | public function getConstraintParameterMap() { |
413 | - if ( $this->constraintParameterMap === null ) { |
|
413 | + if ($this->constraintParameterMap === null) { |
|
414 | 414 | $this->constraintParameterMap = [ |
415 | - 'Commons link' => [ 'namespace' ], |
|
416 | - 'Conflicts with' => [ 'property', 'item' ], |
|
417 | - 'Diff within range' => [ 'property', 'minimum_quantity', 'maximum_quantity' ], |
|
418 | - 'Format' => [ 'pattern' ], |
|
419 | - 'Inverse' => [ 'property' ], |
|
420 | - 'Item' => [ 'property', 'item' ], |
|
421 | - 'Mandatory qualifiers' => [ 'property' ], |
|
415 | + 'Commons link' => ['namespace'], |
|
416 | + 'Conflicts with' => ['property', 'item'], |
|
417 | + 'Diff within range' => ['property', 'minimum_quantity', 'maximum_quantity'], |
|
418 | + 'Format' => ['pattern'], |
|
419 | + 'Inverse' => ['property'], |
|
420 | + 'Item' => ['property', 'item'], |
|
421 | + 'Mandatory qualifiers' => ['property'], |
|
422 | 422 | 'Multi value' => [], |
423 | - 'One of' => [ 'item' ], |
|
423 | + 'One of' => ['item'], |
|
424 | 424 | 'Qualifier' => [], |
425 | - 'Qualifiers' => [ 'property' ], |
|
426 | - 'Range' => [ 'minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date' ], |
|
425 | + 'Qualifiers' => ['property'], |
|
426 | + 'Range' => ['minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date'], |
|
427 | 427 | 'Single value' => [], |
428 | 428 | 'Symmetric' => [], |
429 | - 'Target required claim' => [ 'property', 'item' ], |
|
430 | - 'Type' => [ 'class', 'relation' ], |
|
429 | + 'Target required claim' => ['property', 'item'], |
|
430 | + 'Type' => ['class', 'relation'], |
|
431 | 431 | 'Unique value' => [], |
432 | - 'Value type' => [ 'class', 'relation' ] |
|
432 | + 'Value type' => ['class', 'relation'] |
|
433 | 433 | ]; |
434 | 434 | } |
435 | 435 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @return ConstraintRepository |
441 | 441 | */ |
442 | 442 | public function getConstraintRepository() { |
443 | - if ( $this->constraintRepository === null ) { |
|
443 | + if ($this->constraintRepository === null) { |
|
444 | 444 | $this->constraintRepository = new ConstraintRepository(); |
445 | 445 | } |
446 | 446 |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return CheckResult |
57 | 57 | */ |
58 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
59 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
60 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
58 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
59 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
60 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $propertyId = $context->getSnak()->getPropertyId(); |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | $parameters = []; |
66 | 66 | |
67 | 67 | $bestRankCount = $this->valueCountCheckerHelper->getPropertyCount( |
68 | - $context->getSnakGroup( Context::GROUP_BEST_RANK ), |
|
68 | + $context->getSnakGroup(Context::GROUP_BEST_RANK), |
|
69 | 69 | $propertyId |
70 | 70 | ); |
71 | 71 | |
72 | - if ( $bestRankCount > 1 ) { |
|
72 | + if ($bestRankCount > 1) { |
|
73 | 73 | $nonDeprecatedCount = $this->valueCountCheckerHelper->getPropertyCount( |
74 | - $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ), |
|
74 | + $context->getSnakGroup(Context::GROUP_NON_DEPRECATED), |
|
75 | 75 | $propertyId |
76 | 76 | ); |
77 | - if ( $bestRankCount === $nonDeprecatedCount ) { |
|
77 | + if ($bestRankCount === $nonDeprecatedCount) { |
|
78 | 78 | $messageKey = 'wbqc-violation-message-single-best-value-no-preferred'; |
79 | 79 | } else { |
80 | 80 | $messageKey = 'wbqc-violation-message-single-best-value-multi-preferred'; |
81 | 81 | } |
82 | - $message = new ViolationMessage( $messageKey ); |
|
82 | + $message = new ViolationMessage($messageKey); |
|
83 | 83 | $status = CheckResult::STATUS_VIOLATION; |
84 | 84 | } else { |
85 | 85 | $message = null; |
86 | 86 | $status = CheckResult::STATUS_COMPLIANCE; |
87 | 87 | } |
88 | 88 | |
89 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
89 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
92 | + public function checkConstraintParameters(Constraint $constraint) { |
|
93 | 93 | // no parameters |
94 | 94 | return []; |
95 | 95 | } |