Completed
Push — master ( 3df65a...fb3d7f )
by
unknown
38s queued 11s
created
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +278 added lines, -278 removed lines patch added patch discarded remove patch
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	 * @param array $parameters
78 78
 	 * @throws ConstraintParameterException
79 79
 	 */
80
-	public function checkError( array $parameters ) {
81
-		if ( array_key_exists( '@error', $parameters ) ) {
80
+	public function checkError(array $parameters) {
81
+		if (array_key_exists('@error', $parameters)) {
82 82
 			$error = $parameters['@error'];
83
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
83
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
84 84
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
85 85
 			} else {
86 86
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
87 87
 			}
88
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
88
+			throw new ConstraintParameterException(new ViolationMessage($msg));
89 89
 		}
90 90
 	}
91 91
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @param string $parameterId
96 96
 	 * @throws ConstraintParameterException
97 97
 	 */
98
-	private function requireSingleParameter( array $parameters, $parameterId ) {
99
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
98
+	private function requireSingleParameter(array $parameters, $parameterId) {
99
+		if (count($parameters[$parameterId]) !== 1) {
100 100
 			throw new ConstraintParameterException(
101
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
102
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
101
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
102
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
103 103
 			);
104 104
 		}
105 105
 	}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws ConstraintParameterException
113 113
 	 */
114
-	private function requireValueParameter( Snak $snak, $parameterId ) {
115
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
114
+	private function requireValueParameter(Snak $snak, $parameterId) {
115
+		if (!($snak instanceof PropertyValueSnak)) {
116 116
 			throw new ConstraintParameterException(
117
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
118
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
117
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
118
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
119 119
 			);
120 120
 		}
121 121
 	}
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 	 * @throws ConstraintParameterException
128 128
 	 * @return EntityId
129 129
 	 */
130
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
131
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
132
-		$this->requireValueParameter( $snak, $parameterId );
130
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
131
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
132
+		$this->requireValueParameter($snak, $parameterId);
133 133
 		$value = $snak->getDataValue();
134
-		if ( $value instanceof EntityIdValue ) {
134
+		if ($value instanceof EntityIdValue) {
135 135
 			return $value->getEntityId();
136 136
 		} else {
137 137
 			throw new ConstraintParameterException(
138
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
139
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
140
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
138
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
139
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
140
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
141 141
 			);
142 142
 		}
143 143
 	}
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
149 149
 	 * @return string[] class entity ID serializations
150 150
 	 */
151
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
152
-		$this->checkError( $constraintParameters );
153
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
154
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
151
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
152
+		$this->checkError($constraintParameters);
153
+		$classId = $this->config->get('WBQualityConstraintsClassId');
154
+		if (!array_key_exists($classId, $constraintParameters)) {
155 155
 			throw new ConstraintParameterException(
156
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
157
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
158
-					->withEntityId( new PropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
156
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
157
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
158
+					->withEntityId(new PropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
159 159
 			);
160 160
 		}
161 161
 
162 162
 		$classes = [];
163
-		foreach ( $constraintParameters[$classId] as $class ) {
164
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
163
+		foreach ($constraintParameters[$classId] as $class) {
164
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
165 165
 		}
166 166
 		return $classes;
167 167
 	}
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
173 173
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
174 174
 	 */
175
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
176
-		$this->checkError( $constraintParameters );
177
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
178
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
175
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
176
+		$this->checkError($constraintParameters);
177
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
178
+		if (!array_key_exists($relationId, $constraintParameters)) {
179 179
 			throw new ConstraintParameterException(
180
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
181
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
182
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
180
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
181
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
182
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
183 183
 			);
184 184
 		}
185 185
 
186
-		$this->requireSingleParameter( $constraintParameters, $relationId );
187
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
188
-		if ( !( $relationEntityId instanceof ItemId ) ) {
186
+		$this->requireSingleParameter($constraintParameters, $relationId);
187
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
188
+		if (!($relationEntityId instanceof ItemId)) {
189 189
 			throw new ConstraintParameterException(
190
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
191
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
192
-					->withDataValue( new EntityIdValue( $relationEntityId ), Role::CONSTRAINT_PARAMETER_VALUE )
190
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
191
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
192
+					->withDataValue(new EntityIdValue($relationEntityId), Role::CONSTRAINT_PARAMETER_VALUE)
193 193
 			);
194 194
 		}
195
-		return $this->mapItemId( $relationEntityId, [
196
-			$this->config->get( 'WBQualityConstraintsInstanceOfRelationId' ) => 'instance',
197
-			$this->config->get( 'WBQualityConstraintsSubclassOfRelationId' ) => 'subclass',
198
-			$this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' ) => 'instanceOrSubclass',
199
-		], $relationId );
195
+		return $this->mapItemId($relationEntityId, [
196
+			$this->config->get('WBQualityConstraintsInstanceOfRelationId') => 'instance',
197
+			$this->config->get('WBQualityConstraintsSubclassOfRelationId') => 'subclass',
198
+			$this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId') => 'instanceOrSubclass',
199
+		], $relationId);
200 200
 	}
201 201
 
202 202
 	/**
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
 	 * @throws ConstraintParameterException
207 207
 	 * @return PropertyId
208 208
 	 */
209
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
210
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
211
-		$this->requireValueParameter( $snak, $parameterId );
209
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
210
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
211
+		$this->requireValueParameter($snak, $parameterId);
212 212
 		$value = $snak->getDataValue();
213
-		if ( $value instanceof EntityIdValue ) {
213
+		if ($value instanceof EntityIdValue) {
214 214
 			$id = $value->getEntityId();
215
-			if ( $id instanceof PropertyId ) {
215
+			if ($id instanceof PropertyId) {
216 216
 				return $id;
217 217
 			}
218 218
 		}
219 219
 		throw new ConstraintParameterException(
220
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
221
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
222
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
220
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
221
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
222
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
223 223
 		);
224 224
 	}
225 225
 
@@ -230,33 +230,33 @@  discard block
 block discarded – undo
230 230
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
231 231
 	 * @return PropertyId
232 232
 	 */
233
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
234
-		$this->checkError( $constraintParameters );
235
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
236
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
233
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
234
+		$this->checkError($constraintParameters);
235
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
236
+		if (!array_key_exists($propertyId, $constraintParameters)) {
237 237
 			throw new ConstraintParameterException(
238
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
239
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
240
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
238
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
239
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
240
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
241 241
 			);
242 242
 		}
243 243
 
244
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
245
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
244
+		$this->requireSingleParameter($constraintParameters, $propertyId);
245
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
246 246
 	}
247 247
 
248
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
248
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
249 249
 		$dataValue = $snak->getDataValue();
250
-		if ( $dataValue instanceof EntityIdValue ) {
250
+		if ($dataValue instanceof EntityIdValue) {
251 251
 			$entityId = $dataValue->getEntityId();
252
-			if ( $entityId instanceof ItemId ) {
253
-				return ItemIdSnakValue::fromItemId( $entityId );
252
+			if ($entityId instanceof ItemId) {
253
+				return ItemIdSnakValue::fromItemId($entityId);
254 254
 			}
255 255
 		}
256 256
 		throw new ConstraintParameterException(
257
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
258
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
259
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
257
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
258
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
259
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
260 260
 		);
261 261
 	}
262 262
 
@@ -274,16 +274,16 @@  discard block
 block discarded – undo
274 274
 		$required,
275 275
 		$parameterId = null
276 276
 	) {
277
-		$this->checkError( $constraintParameters );
278
-		if ( $parameterId === null ) {
279
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
277
+		$this->checkError($constraintParameters);
278
+		if ($parameterId === null) {
279
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
280 280
 		}
281
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
282
-			if ( $required ) {
281
+		if (!array_key_exists($parameterId, $constraintParameters)) {
282
+			if ($required) {
283 283
 				throw new ConstraintParameterException(
284
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
285
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
286
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
284
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
285
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
286
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
287 287
 				);
288 288
 			} else {
289 289
 				return [];
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 		}
292 292
 
293 293
 		$values = [];
294
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
295
-			$snak = $this->snakDeserializer->deserialize( $parameter );
296
-			switch ( true ) {
294
+		foreach ($constraintParameters[$parameterId] as $parameter) {
295
+			$snak = $this->snakDeserializer->deserialize($parameter);
296
+			switch (true) {
297 297
 				case $snak instanceof PropertyValueSnak:
298
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
298
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
299 299
 					break;
300 300
 				case $snak instanceof PropertySomeValueSnak:
301 301
 					$values[] = ItemIdSnakValue::someValue();
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
 		bool $required,
324 324
 		string $parameterId
325 325
 	): array {
326
-		return array_map( static function ( ItemIdSnakValue $value ) use ( $parameterId ): ItemId {
327
-			if ( $value->isValue() ) {
326
+		return array_map(static function(ItemIdSnakValue $value) use ($parameterId): ItemId {
327
+			if ($value->isValue()) {
328 328
 				return $value->getItemId();
329 329
 			} else {
330 330
 				throw new ConstraintParameterException(
331
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
332
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
331
+					(new ViolationMessage('wbqc-violation-message-parameter-value'))
332
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
333 333
 				);
334 334
 			}
335 335
 		}, $this->parseItemsParameter(
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 			$constraintTypeItemId,
338 338
 			$required,
339 339
 			$parameterId
340
-		) );
340
+		));
341 341
 	}
342 342
 
343 343
 	/**
@@ -345,18 +345,18 @@  discard block
 block discarded – undo
345 345
 	 * @throws ConstraintParameterException
346 346
 	 * @return mixed elements of $mapping
347 347
 	 */
348
-	private function mapItemId( ItemId $itemId, array $mapping, string $parameterId ) {
348
+	private function mapItemId(ItemId $itemId, array $mapping, string $parameterId) {
349 349
 		$serialization = $itemId->getSerialization();
350
-		if ( array_key_exists( $serialization, $mapping ) ) {
350
+		if (array_key_exists($serialization, $mapping)) {
351 351
 			return $mapping[$serialization];
352 352
 		} else {
353
-			$allowed = array_map( static function ( $id ) {
354
-				return new ItemId( $id );
355
-			}, array_keys( $mapping ) );
353
+			$allowed = array_map(static function($id) {
354
+				return new ItemId($id);
355
+			}, array_keys($mapping));
356 356
 			throw new ConstraintParameterException(
357
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
358
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
359
-					->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
357
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
358
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
359
+					->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
360 360
 			);
361 361
 		}
362 362
 	}
@@ -367,27 +367,27 @@  discard block
 block discarded – undo
367 367
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
368 368
 	 * @return PropertyId[]
369 369
 	 */
370
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
371
-		$this->checkError( $constraintParameters );
372
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
373
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
370
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
371
+		$this->checkError($constraintParameters);
372
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
373
+		if (!array_key_exists($propertyId, $constraintParameters)) {
374 374
 			throw new ConstraintParameterException(
375
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
376
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
377
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
375
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
376
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
377
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
378 378
 			);
379 379
 		}
380 380
 
381 381
 		$parameters = $constraintParameters[$propertyId];
382
-		if ( count( $parameters ) === 1 &&
383
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
382
+		if (count($parameters) === 1 &&
383
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
384 384
 		) {
385 385
 			return [];
386 386
 		}
387 387
 
388 388
 		$properties = [];
389
-		foreach ( $parameters as $parameter ) {
390
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
389
+		foreach ($parameters as $parameter) {
390
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
391 391
 		}
392 392
 		return $properties;
393 393
 	}
@@ -398,16 +398,16 @@  discard block
 block discarded – undo
398 398
 	 * @throws ConstraintParameterException
399 399
 	 * @return DataValue|null
400 400
 	 */
401
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
402
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
403
-		if ( $snak instanceof PropertyValueSnak ) {
401
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
402
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
403
+		if ($snak instanceof PropertyValueSnak) {
404 404
 			return $snak->getDataValue();
405
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
405
+		} elseif ($snak instanceof PropertyNoValueSnak) {
406 406
 			return null;
407 407
 		} else {
408 408
 			throw new ConstraintParameterException(
409
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
410
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
409
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
410
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
411 411
 			);
412 412
 		}
413 413
 	}
@@ -417,10 +417,10 @@  discard block
 block discarded – undo
417 417
 	 * @param string $parameterId
418 418
 	 * @return DataValue|null
419 419
 	 */
420
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
420
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
421 421
 		try {
422
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
423
-		} catch ( ConstraintParameterException $e ) {
422
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
423
+		} catch (ConstraintParameterException $e) {
424 424
 			// unknown value means “now”
425 425
 			return new NowValue();
426 426
 		}
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 	 * @param string $unit
434 434
 	 * @return bool
435 435
 	 */
436
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, $unit ) {
437
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
438
-			!( $max instanceof UnboundedQuantityValue )
436
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, $unit) {
437
+		if (!($min instanceof UnboundedQuantityValue) ||
438
+			!($max instanceof UnboundedQuantityValue)
439 439
 		) {
440 440
 			return false;
441 441
 		}
442 442
 
443
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
443
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
444 444
 	}
445 445
 
446 446
 	/**
@@ -453,42 +453,42 @@  discard block
 block discarded – undo
453 453
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
454 454
 	 * @return DataValue[] if the parameter is invalid or missing
455 455
 	 */
456
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
457
-		$this->checkError( $constraintParameters );
458
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
459
-			!array_key_exists( $maximumId, $constraintParameters )
456
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
457
+		$this->checkError($constraintParameters);
458
+		if (!array_key_exists($minimumId, $constraintParameters) ||
459
+			!array_key_exists($maximumId, $constraintParameters)
460 460
 		) {
461 461
 			throw new ConstraintParameterException(
462
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
463
-					->withDataValueType( $type )
464
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
465
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
466
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
462
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
463
+					->withDataValueType($type)
464
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
465
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
466
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
467 467
 			);
468 468
 		}
469 469
 
470
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
471
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
470
+		$this->requireSingleParameter($constraintParameters, $minimumId);
471
+		$this->requireSingleParameter($constraintParameters, $maximumId);
472 472
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
473
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
474
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
473
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
474
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
475 475
 
476
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
477
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
476
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
477
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
478 478
 			throw new ConstraintParameterException(
479
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
479
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
480 480
 			);
481 481
 		}
482
-		if ( $min === null && $max === null ||
483
-			$min !== null && $max !== null && $min->equals( $max ) ) {
482
+		if ($min === null && $max === null ||
483
+			$min !== null && $max !== null && $min->equals($max)) {
484 484
 			throw new ConstraintParameterException(
485
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
486
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
487
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
485
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
486
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
487
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
488 488
 			);
489 489
 		}
490 490
 
491
-		return [ $min, $max ];
491
+		return [$min, $max];
492 492
 	}
493 493
 
494 494
 	/**
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
499 499
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
500 500
 	 */
501
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
501
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
502 502
 		return $this->parseRangeParameter(
503 503
 			$constraintParameters,
504
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
505
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
504
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
505
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
506 506
 			$constraintTypeItemId,
507 507
 			'quantity'
508 508
 		);
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
516 516
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
517 517
 	 */
518
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
518
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
519 519
 		return $this->parseRangeParameter(
520 520
 			$constraintParameters,
521
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
522
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
521
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
522
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
523 523
 			$constraintTypeItemId,
524 524
 			'time'
525 525
 		);
@@ -532,17 +532,17 @@  discard block
 block discarded – undo
532 532
 	 * @throws ConstraintParameterException
533 533
 	 * @return string
534 534
 	 */
535
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
536
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
537
-		$this->requireValueParameter( $snak, $parameterId );
535
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
536
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
537
+		$this->requireValueParameter($snak, $parameterId);
538 538
 		$value = $snak->getDataValue();
539
-		if ( $value instanceof StringValue ) {
539
+		if ($value instanceof StringValue) {
540 540
 			return $value->getValue();
541 541
 		} else {
542 542
 			throw new ConstraintParameterException(
543
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
544
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
545
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
543
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
544
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
545
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
546 546
 			);
547 547
 		}
548 548
 	}
@@ -553,15 +553,15 @@  discard block
 block discarded – undo
553 553
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
554 554
 	 * @return string
555 555
 	 */
556
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
557
-		$this->checkError( $constraintParameters );
558
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
559
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
556
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
557
+		$this->checkError($constraintParameters);
558
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
559
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
560 560
 			return '';
561 561
 		}
562 562
 
563
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
564
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
563
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
564
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
565 565
 	}
566 566
 
567 567
 	/**
@@ -570,19 +570,19 @@  discard block
 block discarded – undo
570 570
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
571 571
 	 * @return string
572 572
 	 */
573
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
574
-		$this->checkError( $constraintParameters );
575
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
576
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
573
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
574
+		$this->checkError($constraintParameters);
575
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
576
+		if (!array_key_exists($formatId, $constraintParameters)) {
577 577
 			throw new ConstraintParameterException(
578
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
579
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
580
-					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
578
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
579
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
580
+					->withEntityId(new PropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
581 581
 			);
582 582
 		}
583 583
 
584
-		$this->requireSingleParameter( $constraintParameters, $formatId );
585
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
584
+		$this->requireSingleParameter($constraintParameters, $formatId);
585
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
586 586
 	}
587 587
 
588 588
 	/**
@@ -590,16 +590,16 @@  discard block
 block discarded – undo
590 590
 	 * @throws ConstraintParameterException if the parameter is invalid
591 591
 	 * @return EntityId[]
592 592
 	 */
593
-	public function parseExceptionParameter( array $constraintParameters ) {
594
-		$this->checkError( $constraintParameters );
595
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
596
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
593
+	public function parseExceptionParameter(array $constraintParameters) {
594
+		$this->checkError($constraintParameters);
595
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
596
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
597 597
 			return [];
598 598
 		}
599 599
 
600 600
 		return array_map(
601
-			function ( $snakSerialization ) use ( $exceptionId ) {
602
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
601
+			function($snakSerialization) use ($exceptionId) {
602
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
603 603
 			},
604 604
 			$constraintParameters[$exceptionId]
605 605
 		);
@@ -610,39 +610,39 @@  discard block
 block discarded – undo
610 610
 	 * @throws ConstraintParameterException if the parameter is invalid
611 611
 	 * @return string|null 'mandatory', 'suggestion' or null
612 612
 	 */
613
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
614
-		$this->checkError( $constraintParameters );
615
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
616
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
613
+	public function parseConstraintStatusParameter(array $constraintParameters) {
614
+		$this->checkError($constraintParameters);
615
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
616
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
617 617
 			return null;
618 618
 		}
619 619
 
620
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
621
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
622
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
623
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
624
-			$supportedStatuses[] = new ItemId( $suggestionId );
620
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
621
+		$supportedStatuses = [new ItemId($mandatoryId)];
622
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
623
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
624
+			$supportedStatuses[] = new ItemId($suggestionId);
625 625
 		} else {
626 626
 			$suggestionId = null;
627 627
 		}
628 628
 
629
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
630
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
631
-		$this->requireValueParameter( $snak, $constraintStatusId );
629
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
630
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
631
+		$this->requireValueParameter($snak, $constraintStatusId);
632 632
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
633 633
 		$dataValue = $snak->getDataValue();
634 634
 		'@phan-var EntityIdValue $dataValue';
635 635
 		$entityId = $dataValue->getEntityId();
636 636
 		$statusId = $entityId->getSerialization();
637 637
 
638
-		if ( $statusId === $mandatoryId ) {
638
+		if ($statusId === $mandatoryId) {
639 639
 			return 'mandatory';
640
-		} elseif ( $statusId === $suggestionId ) {
640
+		} elseif ($statusId === $suggestionId) {
641 641
 			return 'suggestion';
642 642
 		} else {
643 643
 			throw new ConstraintParameterException(
644
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
645
-					->withEntityId( new PropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
644
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
645
+					->withEntityId(new PropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
646 646
 					->withEntityIdList(
647 647
 						$supportedStatuses,
648 648
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -658,12 +658,12 @@  discard block
 block discarded – undo
658 658
 	 * @return void
659 659
 	 * @throws ConstraintParameterException
660 660
 	 */
661
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
662
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
661
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
662
+		if (!($dataValue instanceof MonolingualTextValue)) {
663 663
 			throw new ConstraintParameterException(
664
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
665
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
666
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
664
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
665
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
666
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
667 667
 			);
668 668
 		}
669 669
 	}
@@ -676,31 +676,31 @@  discard block
 block discarded – undo
676 676
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
677 677
 	 * @return MultilingualTextValue
678 678
 	 */
679
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
679
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
680 680
 		$result = [];
681 681
 
682
-		foreach ( $snakSerializations as $snakSerialization ) {
683
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
684
-			$this->requireValueParameter( $snak, $parameterId );
682
+		foreach ($snakSerializations as $snakSerialization) {
683
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
684
+			$this->requireValueParameter($snak, $parameterId);
685 685
 
686 686
 			$value = $snak->getDataValue();
687
-			$this->requireMonolingualTextParameter( $value, $parameterId );
687
+			$this->requireMonolingualTextParameter($value, $parameterId);
688 688
 			/** @var MonolingualTextValue $value */
689 689
 			'@phan-var MonolingualTextValue $value';
690 690
 
691 691
 			$code = $value->getLanguageCode();
692
-			if ( array_key_exists( $code, $result ) ) {
692
+			if (array_key_exists($code, $result)) {
693 693
 				throw new ConstraintParameterException(
694
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
695
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
696
-						->withLanguage( $code )
694
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
695
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
696
+						->withLanguage($code)
697 697
 				);
698 698
 			}
699 699
 
700 700
 			$result[$code] = $value;
701 701
 		}
702 702
 
703
-		return new MultilingualTextValue( $result );
703
+		return new MultilingualTextValue($result);
704 704
 	}
705 705
 
706 706
 	/**
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 	 * @throws ConstraintParameterException if the parameter is invalid
709 709
 	 * @return MultilingualTextValue
710 710
 	 */
711
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
712
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
711
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
712
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
713 713
 
714
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
715
-			return new MultilingualTextValue( [] );
714
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
715
+			return new MultilingualTextValue([]);
716 716
 		}
717 717
 
718 718
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		array $validScopes
738 738
 	) {
739 739
 		$contextTypes = [];
740
-		$parameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
740
+		$parameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
741 741
 		$itemIds = $this->parseItemIdsParameter(
742 742
 			$constraintParameters,
743 743
 			$constraintTypeItemId,
@@ -745,22 +745,22 @@  discard block
 block discarded – undo
745 745
 			$parameterId
746 746
 		);
747 747
 
748
-		if ( $itemIds === [] ) {
748
+		if ($itemIds === []) {
749 749
 			return null;
750 750
 		}
751 751
 
752
-		foreach ( $itemIds as $itemId ) {
753
-			$contextTypes[] = $this->parseContextTypeItemId( $itemId, 'constraint scope', $parameterId );
752
+		foreach ($itemIds as $itemId) {
753
+			$contextTypes[] = $this->parseContextTypeItemId($itemId, 'constraint scope', $parameterId);
754 754
 		}
755 755
 
756
-		$invalidScopes = array_diff( $contextTypes, $validScopes );
757
-		if ( $invalidScopes !== [] ) {
758
-			$invalidScope = array_pop( $invalidScopes );
756
+		$invalidScopes = array_diff($contextTypes, $validScopes);
757
+		if ($invalidScopes !== []) {
758
+			$invalidScope = array_pop($invalidScopes);
759 759
 			throw new ConstraintParameterException(
760
-				( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
761
-					->withConstraintScope( $invalidScope, Role::CONSTRAINT_PARAMETER_VALUE )
762
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
763
-					->withConstraintScopeList( $validScopes, Role::CONSTRAINT_PARAMETER_VALUE )
760
+				(new ViolationMessage('wbqc-violation-message-invalid-scope'))
761
+					->withConstraintScope($invalidScope, Role::CONSTRAINT_PARAMETER_VALUE)
762
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
763
+					->withConstraintScopeList($validScopes, Role::CONSTRAINT_PARAMETER_VALUE)
764 764
 			);
765 765
 		}
766 766
 
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 	 * @param ItemId $unitId
774 774
 	 * @return string unit
775 775
 	 */
776
-	private function parseUnitParameter( ItemId $unitId ) {
777
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
776
+	private function parseUnitParameter(ItemId $unitId) {
777
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
778 778
 	}
779 779
 
780 780
 	/**
@@ -784,23 +784,23 @@  discard block
 block discarded – undo
784 784
 	 * @return UnitsParameter
785 785
 	 * @throws ConstraintParameterException
786 786
 	 */
787
-	private function parseUnitItem( ItemIdSnakValue $item ) {
788
-		switch ( true ) {
787
+	private function parseUnitItem(ItemIdSnakValue $item) {
788
+		switch (true) {
789 789
 			case $item->isValue():
790
-				$unit = $this->parseUnitParameter( $item->getItemId() );
790
+				$unit = $this->parseUnitParameter($item->getItemId());
791 791
 				return new UnitsParameter(
792
-					[ $item->getItemId() ],
793
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
792
+					[$item->getItemId()],
793
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
794 794
 					false
795 795
 				);
796 796
 			case $item->isSomeValue():
797
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
797
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
798 798
 				throw new ConstraintParameterException(
799
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
800
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
799
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
800
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
801 801
 				);
802 802
 			case $item->isNoValue():
803
-				return new UnitsParameter( [], [], true );
803
+				return new UnitsParameter([], [], true);
804 804
 		}
805 805
 	}
806 806
 
@@ -810,43 +810,43 @@  discard block
 block discarded – undo
810 810
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
811 811
 	 * @return UnitsParameter
812 812
 	 */
813
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
814
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
813
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
814
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
815 815
 		$unitItems = [];
816 816
 		$unitQuantities = [];
817 817
 		$unitlessAllowed = false;
818 818
 
819
-		foreach ( $items as $item ) {
820
-			$unit = $this->parseUnitItem( $item );
821
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
822
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
819
+		foreach ($items as $item) {
820
+			$unit = $this->parseUnitItem($item);
821
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
822
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
823 823
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
824 824
 		}
825 825
 
826
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
826
+		if ($unitQuantities === [] && !$unitlessAllowed) {
827 827
 			throw new LogicException(
828 828
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
829 829
 			);
830 830
 		}
831 831
 
832
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
832
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
833 833
 	}
834 834
 
835
-	private function parseEntityTypeItemId( ItemId $itemId ): EntityTypesParameter {
835
+	private function parseEntityTypeItemId(ItemId $itemId): EntityTypesParameter {
836 836
 		$entityType = $this->mapItemId(
837 837
 			$itemId,
838 838
 			[
839
-				$this->config->get( 'WBQualityConstraintsWikibaseItemId' ) => 'item',
840
-				$this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) => 'property',
841
-				$this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) => 'lexeme',
842
-				$this->config->get( 'WBQualityConstraintsWikibaseFormId' ) => 'form',
843
-				$this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) => 'sense',
844
-				$this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) => 'mediainfo',
839
+				$this->config->get('WBQualityConstraintsWikibaseItemId') => 'item',
840
+				$this->config->get('WBQualityConstraintsWikibasePropertyId') => 'property',
841
+				$this->config->get('WBQualityConstraintsWikibaseLexemeId') => 'lexeme',
842
+				$this->config->get('WBQualityConstraintsWikibaseFormId') => 'form',
843
+				$this->config->get('WBQualityConstraintsWikibaseSenseId') => 'sense',
844
+				$this->config->get('WBQualityConstraintsWikibaseMediaInfoId') => 'mediainfo',
845 845
 			],
846
-			$this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' )
846
+			$this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId')
847 847
 		);
848 848
 
849
-		return new EntityTypesParameter( [ $entityType ], [ $itemId ] );
849
+		return new EntityTypesParameter([$entityType], [$itemId]);
850 850
 	}
851 851
 
852 852
 	/**
@@ -855,32 +855,32 @@  discard block
 block discarded – undo
855 855
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
856 856
 	 * @return EntityTypesParameter
857 857
 	 */
858
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
858
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
859 859
 		$entityTypes = [];
860 860
 		$entityTypeItemIds = [];
861 861
 		$itemIds = $this->parseItemIdsParameter(
862 862
 			$constraintParameters,
863 863
 			$constraintTypeItemId,
864 864
 			true,
865
-			$this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' )
865
+			$this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId')
866 866
 		);
867 867
 
868
-		foreach ( $itemIds as $itemId ) {
869
-			$entityType = $this->parseEntityTypeItemId( $itemId );
870
-			$entityTypes = array_merge( $entityTypes, $entityType->getEntityTypes() );
871
-			$entityTypeItemIds = array_merge( $entityTypeItemIds, $entityType->getEntityTypeItemIds() );
868
+		foreach ($itemIds as $itemId) {
869
+			$entityType = $this->parseEntityTypeItemId($itemId);
870
+			$entityTypes = array_merge($entityTypes, $entityType->getEntityTypes());
871
+			$entityTypeItemIds = array_merge($entityTypeItemIds, $entityType->getEntityTypeItemIds());
872 872
 		}
873 873
 
874
-		if ( empty( $entityTypes ) ) {
874
+		if (empty($entityTypes)) {
875 875
 			// @codeCoverageIgnoreStart
876 876
 			throw new LogicException(
877
-				'The "entity types" parameter is required, ' .
877
+				'The "entity types" parameter is required, '.
878 878
 				'and yet we seem to be missing any allowed entity type'
879 879
 			);
880 880
 			// @codeCoverageIgnoreEnd
881 881
 		}
882 882
 
883
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
883
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
884 884
 	}
885 885
 
886 886
 	/**
@@ -888,18 +888,18 @@  discard block
 block discarded – undo
888 888
 	 * @throws ConstraintParameterException if the parameter is invalid
889 889
 	 * @return PropertyId[]
890 890
 	 */
891
-	public function parseSeparatorsParameter( array $constraintParameters ) {
892
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
891
+	public function parseSeparatorsParameter(array $constraintParameters) {
892
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
893 893
 
894
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
894
+		if (!array_key_exists($separatorId, $constraintParameters)) {
895 895
 			return [];
896 896
 		}
897 897
 
898 898
 		$parameters = $constraintParameters[$separatorId];
899 899
 		$separators = [];
900 900
 
901
-		foreach ( $parameters as $parameter ) {
902
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
901
+		foreach ($parameters as $parameter) {
902
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
903 903
 		}
904 904
 
905 905
 		return $separators;
@@ -914,22 +914,22 @@  discard block
 block discarded – undo
914 914
 	 * @return string one of the Context::TYPE_* constants
915 915
 	 * @throws ConstraintParameterException
916 916
 	 */
917
-	private function parseContextTypeItemId( ItemId $itemId, $use, $parameterId ) {
918
-		if ( $use === 'constraint scope' ) {
917
+	private function parseContextTypeItemId(ItemId $itemId, $use, $parameterId) {
918
+		if ($use === 'constraint scope') {
919 919
 			$mapping = [
920
-				$this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ) => Context::TYPE_STATEMENT,
921
-				$this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ) => Context::TYPE_QUALIFIER,
922
-				$this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ) => Context::TYPE_REFERENCE,
920
+				$this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId') => Context::TYPE_STATEMENT,
921
+				$this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId') => Context::TYPE_QUALIFIER,
922
+				$this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId') => Context::TYPE_REFERENCE,
923 923
 			];
924 924
 		} else {
925 925
 			$mapping = [
926
-				$this->config->get( 'WBQualityConstraintsAsMainValueId' ) => Context::TYPE_STATEMENT,
927
-				$this->config->get( 'WBQualityConstraintsAsQualifiersId' ) => Context::TYPE_QUALIFIER,
928
-				$this->config->get( 'WBQualityConstraintsAsReferencesId' ) => Context::TYPE_REFERENCE,
926
+				$this->config->get('WBQualityConstraintsAsMainValueId') => Context::TYPE_STATEMENT,
927
+				$this->config->get('WBQualityConstraintsAsQualifiersId') => Context::TYPE_QUALIFIER,
928
+				$this->config->get('WBQualityConstraintsAsReferencesId') => Context::TYPE_REFERENCE,
929 929
 			];
930 930
 		}
931 931
 
932
-		return $this->mapItemId( $itemId, $mapping, $parameterId );
932
+		return $this->mapItemId($itemId, $mapping, $parameterId);
933 933
 	}
934 934
 
935 935
 	/**
@@ -938,9 +938,9 @@  discard block
 block discarded – undo
938 938
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
939 939
 	 * @return string[] list of Context::TYPE_* constants
940 940
 	 */
941
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
941
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
942 942
 		$contextTypes = [];
943
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
943
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
944 944
 		$itemIds = $this->parseItemIdsParameter(
945 945
 			$constraintParameters,
946 946
 			$constraintTypeItemId,
@@ -948,14 +948,14 @@  discard block
 block discarded – undo
948 948
 			$parameterId
949 949
 		);
950 950
 
951
-		foreach ( $itemIds as $itemId ) {
952
-			$contextTypes[] = $this->parseContextTypeItemId( $itemId, 'property scope', $parameterId );
951
+		foreach ($itemIds as $itemId) {
952
+			$contextTypes[] = $this->parseContextTypeItemId($itemId, 'property scope', $parameterId);
953 953
 		}
954 954
 
955
-		if ( empty( $contextTypes ) ) {
955
+		if (empty($contextTypes)) {
956 956
 			// @codeCoverageIgnoreStart
957 957
 			throw new LogicException(
958
-				'The "property scope" parameter is required, ' .
958
+				'The "property scope" parameter is required, '.
959 959
 				'and yet we seem to be missing any allowed scope'
960 960
 			);
961 961
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.