Completed
Push — master ( 9dde06...dd6d6f )
by
unknown
02:52
created
src/ConstraintReportFactory.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	public static function getDefaultInstance() {
149 149
 		static $instance = null;
150 150
 
151
-		if ( $instance === null ) {
151
+		if ($instance === null) {
152 152
 			$wikibaseRepo = WikibaseRepo::getDefaultInstance();
153 153
 			$config = MediaWikiServices::getInstance()->getMainConfig();
154 154
 			$titleParser = MediaWikiServices::getInstance()->getTitleParser();
@@ -211,21 +211,21 @@  discard block
 block discarded – undo
211 211
 	 * @return DelegatingConstraintChecker
212 212
 	 */
213 213
 	public function getConstraintChecker() {
214
-		if ( $this->delegatingConstraintChecker === null ) {
214
+		if ($this->delegatingConstraintChecker === null) {
215 215
 			$this->delegatingConstraintChecker = new DelegatingConstraintChecker(
216 216
 				$this->lookup,
217 217
 				$this->getConstraintCheckerMap(),
218
-				new CachingConstraintLookup( $this->getConstraintRepository() ),
218
+				new CachingConstraintLookup($this->getConstraintRepository()),
219 219
 				$this->constraintParameterParser,
220 220
 				$this->statementGuidParser,
221 221
 				new LoggingHelper(
222 222
 					$this->dataFactory,
223
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
223
+					LoggerFactory::getInstance('WikibaseQualityConstraints'),
224 224
 					$this->config
225 225
 				),
226
-				$this->config->get( 'WBQualityConstraintsCheckQualifiers' ),
227
-				$this->config->get( 'WBQualityConstraintsCheckReferences' ),
228
-				$this->config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
226
+				$this->config->get('WBQualityConstraintsCheckQualifiers'),
227
+				$this->config->get('WBQualityConstraintsCheckReferences'),
228
+				$this->config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
229 229
 			);
230 230
 		}
231 231
 
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 	 * @return ConstraintChecker[]
237 237
 	 */
238 238
 	private function getConstraintCheckerMap() {
239
-		if ( $this->constraintCheckerMap === null ) {
239
+		if ($this->constraintCheckerMap === null) {
240 240
 			$connectionCheckerHelper = new ConnectionCheckerHelper();
241
-			$rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter );
242
-			if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) {
241
+			$rangeCheckerHelper = new RangeCheckerHelper($this->config, $this->unitConverter);
242
+			if ($this->config->get('WBQualityConstraintsSparqlEndpoint') !== '') {
243 243
 				$sparqlHelper = new SparqlHelper(
244 244
 					$this->config,
245 245
 					$this->rdfVocabulary,
@@ -261,116 +261,116 @@  discard block
 block discarded – undo
261 261
 			);
262 262
 
263 263
 			$this->constraintCheckerMap = [
264
-				$this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
264
+				$this->config->get('WBQualityConstraintsConflictsWithConstraintId')
265 265
 					=> new ConflictsWithChecker(
266 266
 						$this->lookup,
267 267
 						$this->constraintParameterParser,
268 268
 						$connectionCheckerHelper
269 269
 					),
270
-				$this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
270
+				$this->config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
271 271
 					=> new ItemChecker(
272 272
 						$this->lookup,
273 273
 						$this->constraintParameterParser,
274 274
 						$connectionCheckerHelper
275 275
 					),
276
-				$this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
276
+				$this->config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
277 277
 					=> new TargetRequiredClaimChecker(
278 278
 						$this->lookup,
279 279
 						$this->constraintParameterParser,
280 280
 						$connectionCheckerHelper
281 281
 					),
282
-				$this->config->get( 'WBQualityConstraintsSymmetricConstraintId' )
282
+				$this->config->get('WBQualityConstraintsSymmetricConstraintId')
283 283
 					=> new SymmetricChecker(
284 284
 						$this->lookup,
285 285
 						$connectionCheckerHelper
286 286
 					),
287
-				$this->config->get( 'WBQualityConstraintsInverseConstraintId' )
287
+				$this->config->get('WBQualityConstraintsInverseConstraintId')
288 288
 					=> new InverseChecker(
289 289
 						$this->lookup,
290 290
 						$this->constraintParameterParser,
291 291
 						$connectionCheckerHelper
292 292
 					),
293
-				$this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
293
+				$this->config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
294 294
 					=> new QualifierChecker(),
295
-				$this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
295
+				$this->config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
296 296
 					=> new QualifiersChecker(
297 297
 						$this->constraintParameterParser
298 298
 					),
299
-				$this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
299
+				$this->config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
300 300
 					=> new MandatoryQualifiersChecker(
301 301
 						$this->constraintParameterParser
302 302
 					),
303
-				$this->config->get( 'WBQualityConstraintsRangeConstraintId' )
303
+				$this->config->get('WBQualityConstraintsRangeConstraintId')
304 304
 					=> new RangeChecker(
305 305
 						$this->propertyDataTypeLookup,
306 306
 						$this->constraintParameterParser,
307 307
 						$rangeCheckerHelper
308 308
 					),
309
-				$this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
309
+				$this->config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
310 310
 					=> new DiffWithinRangeChecker(
311 311
 						$this->constraintParameterParser,
312 312
 						$rangeCheckerHelper,
313 313
 						$this->config
314 314
 					),
315
-				$this->config->get( 'WBQualityConstraintsTypeConstraintId' )
315
+				$this->config->get('WBQualityConstraintsTypeConstraintId')
316 316
 					=> new TypeChecker(
317 317
 						$this->lookup,
318 318
 						$this->constraintParameterParser,
319 319
 						$typeCheckerHelper,
320 320
 						$this->config
321 321
 					),
322
-				$this->config->get( 'WBQualityConstraintsValueTypeConstraintId' )
322
+				$this->config->get('WBQualityConstraintsValueTypeConstraintId')
323 323
 					=> new ValueTypeChecker(
324 324
 						$this->lookup,
325 325
 						$this->constraintParameterParser,
326 326
 						$typeCheckerHelper,
327 327
 						$this->config
328 328
 					),
329
-				$this->config->get( 'WBQualityConstraintsSingleValueConstraintId' )
330
-					=> new SingleValueChecker( $this->constraintParameterParser ),
331
-				$this->config->get( 'WBQualityConstraintsMultiValueConstraintId' )
332
-					=> new MultiValueChecker( $this->constraintParameterParser ),
333
-				$this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
329
+				$this->config->get('WBQualityConstraintsSingleValueConstraintId')
330
+					=> new SingleValueChecker($this->constraintParameterParser),
331
+				$this->config->get('WBQualityConstraintsMultiValueConstraintId')
332
+					=> new MultiValueChecker($this->constraintParameterParser),
333
+				$this->config->get('WBQualityConstraintsDistinctValuesConstraintId')
334 334
 					=> new UniqueValueChecker(
335 335
 						$sparqlHelper
336 336
 					),
337
-				$this->config->get( 'WBQualityConstraintsFormatConstraintId' )
337
+				$this->config->get('WBQualityConstraintsFormatConstraintId')
338 338
 					=> new FormatChecker(
339 339
 						$this->constraintParameterParser,
340 340
 						$this->config,
341 341
 						$sparqlHelper
342 342
 					),
343
-				$this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
343
+				$this->config->get('WBQualityConstraintsCommonsLinkConstraintId')
344 344
 					=> new CommonsLinkChecker(
345 345
 						$this->constraintParameterParser,
346 346
 						$this->titleParser
347 347
 					),
348
-				$this->config->get( 'WBQualityConstraintsOneOfConstraintId' )
348
+				$this->config->get('WBQualityConstraintsOneOfConstraintId')
349 349
 					=> new OneOfChecker(
350 350
 						$this->constraintParameterParser
351 351
 					),
352
-				$this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
352
+				$this->config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
353 353
 					=> new ValueOnlyChecker(),
354
-				$this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
354
+				$this->config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
355 355
 					=> new ReferenceChecker(),
356
-				$this->config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
356
+				$this->config->get('WBQualityConstraintsNoBoundsConstraintId')
357 357
 					=> new NoBoundsChecker(),
358
-				$this->config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
358
+				$this->config->get('WBQualityConstraintsAllowedUnitsConstraintId')
359 359
 					=> new AllowedUnitsChecker(
360 360
 						$this->constraintParameterParser,
361 361
 						$this->unitConverter
362 362
 					),
363
-				$this->config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
364
-					=> new SingleBestValueChecker( $this->constraintParameterParser ),
365
-				$this->config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
363
+				$this->config->get('WBQualityConstraintsSingleBestValueConstraintId')
364
+					=> new SingleBestValueChecker($this->constraintParameterParser),
365
+				$this->config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
366 366
 					=> new EntityTypeChecker(
367 367
 						$this->constraintParameterParser
368 368
 					),
369
-				$this->config->get( 'WBQualityConstraintsNoneOfConstraintId' )
369
+				$this->config->get('WBQualityConstraintsNoneOfConstraintId')
370 370
 					=> new NoneOfChecker(
371 371
 						$this->constraintParameterParser
372 372
 					),
373
-				$this->config->get( 'WBQualityConstraintsIntegerConstraintId' )
373
+				$this->config->get('WBQualityConstraintsIntegerConstraintId')
374 374
 					=> new IntegerChecker(),
375 375
 			];
376 376
 		}
@@ -382,26 +382,26 @@  discard block
 block discarded – undo
382 382
 	 * @return array[]
383 383
 	 */
384 384
 	public function getConstraintParameterMap() {
385
-		if ( $this->constraintParameterMap === null ) {
385
+		if ($this->constraintParameterMap === null) {
386 386
 			$this->constraintParameterMap = [
387
-				'Commons link' => [ 'namespace' ],
388
-				'Conflicts with' => [ 'property', 'item' ],
389
-				'Diff within range' => [ 'property', 'minimum_quantity', 'maximum_quantity' ],
390
-				'Format' => [ 'pattern' ],
391
-				'Inverse' => [ 'property' ],
392
-				'Item' => [ 'property', 'item' ],
393
-				'Mandatory qualifiers' => [ 'property' ],
387
+				'Commons link' => ['namespace'],
388
+				'Conflicts with' => ['property', 'item'],
389
+				'Diff within range' => ['property', 'minimum_quantity', 'maximum_quantity'],
390
+				'Format' => ['pattern'],
391
+				'Inverse' => ['property'],
392
+				'Item' => ['property', 'item'],
393
+				'Mandatory qualifiers' => ['property'],
394 394
 				'Multi value' => [],
395
-				'One of' => [ 'item' ],
395
+				'One of' => ['item'],
396 396
 				'Qualifier' => [],
397
-				'Qualifiers' => [ 'property' ],
398
-				'Range' => [ 'minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date' ],
397
+				'Qualifiers' => ['property'],
398
+				'Range' => ['minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date'],
399 399
 				'Single value' => [],
400 400
 				'Symmetric' => [],
401
-				'Target required claim' => [ 'property', 'item' ],
402
-				'Type' => [ 'class', 'relation' ],
401
+				'Target required claim' => ['property', 'item'],
402
+				'Type' => ['class', 'relation'],
403 403
 				'Unique value' => [],
404
-				'Value type' => [ 'class', 'relation' ]
404
+				'Value type' => ['class', 'relation']
405 405
 			];
406 406
 		}
407 407
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * @return ConstraintRepository
413 413
 	 */
414 414
 	public function getConstraintRepository() {
415
-		if ( $this->constraintRepository === null ) {
415
+		if ($this->constraintRepository === null) {
416 416
 			$this->constraintRepository = new ConstraintRepository();
417 417
 		}
418 418
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/IntegerChecker.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -40,31 +40,31 @@  discard block
 block discarded – undo
40 40
 		];
41 41
 	}
42 42
 
43
-	public function checkConstraint( Context $context, Constraint $constraint ) {
44
-		if ( $context->getSnak()->getType() !== 'value' ) {
45
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
43
+	public function checkConstraint(Context $context, Constraint $constraint) {
44
+		if ($context->getSnak()->getType() !== 'value') {
45
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
46 46
 		}
47 47
 
48 48
 		/** @var PropertyValueSnak $snak */
49 49
 		$snak = $context->getSnak();
50 50
 
51
-		if ( $snak->getDataValue() instanceof DecimalValue ) {
52
-			return $this->checkDecimalValue( $snak->getDataValue(), $context, $constraint );
53
-		} elseif ( $snak->getDataValue() instanceof UnboundedQuantityValue ) {
54
-			return $this->checkDecimalValue( $snak->getDataValue()->getAmount(), $context, $constraint );
51
+		if ($snak->getDataValue() instanceof DecimalValue) {
52
+			return $this->checkDecimalValue($snak->getDataValue(), $context, $constraint);
53
+		} elseif ($snak->getDataValue() instanceof UnboundedQuantityValue) {
54
+			return $this->checkDecimalValue($snak->getDataValue()->getAmount(), $context, $constraint);
55 55
 		}
56 56
 
57
-		return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
57
+		return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
58 58
 	}
59 59
 
60
-	private function checkDecimalValue( DecimalValue $decimalValue, Context $context, Constraint $constraint ) {
61
-		if ( $decimalValue->getTrimmed()->getFractionalPart() === '' ) {
62
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
60
+	private function checkDecimalValue(DecimalValue $decimalValue, Context $context, Constraint $constraint) {
61
+		if ($decimalValue->getTrimmed()->getFractionalPart() === '') {
62
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
63 63
 		}
64 64
 
65
-		$message = ( new ViolationMessage( 'wbqc-violation-message-integer' ) )
66
-			->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
67
-			->withDataValue( $decimalValue );
65
+		$message = (new ViolationMessage('wbqc-violation-message-integer'))
66
+			->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
67
+			->withDataValue($decimalValue);
68 68
 		return new CheckResult(
69 69
 			$context,
70 70
 			$constraint,
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		);
75 75
 	}
76 76
 
77
-	public function checkConstraintParameters( Constraint $constraint ) {
77
+	public function checkConstraintParameters(Constraint $constraint) {
78 78
 		// no parameters
79 79
 		return [];
80 80
 	}
Please login to merge, or discard this patch.