Completed
Push — master ( fb3d7f...5f7797 )
by
unknown
01:19 queued 11s
created
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +270 added lines, -270 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,23 +745,23 @@  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 752
 		$mapping = $this->getConstraintScopeContextTypeMapping();
753
-		foreach ( $itemIds as $itemId ) {
754
-			$contextTypes[] = $this->mapItemId( $itemId, $mapping, $parameterId );
753
+		foreach ($itemIds as $itemId) {
754
+			$contextTypes[] = $this->mapItemId($itemId, $mapping, $parameterId);
755 755
 		}
756 756
 
757
-		$invalidScopes = array_diff( $contextTypes, $validScopes );
758
-		if ( $invalidScopes !== [] ) {
759
-			$invalidScope = array_pop( $invalidScopes );
757
+		$invalidScopes = array_diff($contextTypes, $validScopes);
758
+		if ($invalidScopes !== []) {
759
+			$invalidScope = array_pop($invalidScopes);
760 760
 			throw new ConstraintParameterException(
761
-				( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
762
-					->withConstraintScope( $invalidScope, Role::CONSTRAINT_PARAMETER_VALUE )
763
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
764
-					->withConstraintScopeList( $validScopes, Role::CONSTRAINT_PARAMETER_VALUE )
761
+				(new ViolationMessage('wbqc-violation-message-invalid-scope'))
762
+					->withConstraintScope($invalidScope, Role::CONSTRAINT_PARAMETER_VALUE)
763
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
764
+					->withConstraintScopeList($validScopes, Role::CONSTRAINT_PARAMETER_VALUE)
765 765
 			);
766 766
 		}
767 767
 
@@ -774,8 +774,8 @@  discard block
 block discarded – undo
774 774
 	 * @param ItemId $unitId
775 775
 	 * @return string unit
776 776
 	 */
777
-	private function parseUnitParameter( ItemId $unitId ) {
778
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
777
+	private function parseUnitParameter(ItemId $unitId) {
778
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
779 779
 	}
780 780
 
781 781
 	/**
@@ -785,23 +785,23 @@  discard block
 block discarded – undo
785 785
 	 * @return UnitsParameter
786 786
 	 * @throws ConstraintParameterException
787 787
 	 */
788
-	private function parseUnitItem( ItemIdSnakValue $item ) {
789
-		switch ( true ) {
788
+	private function parseUnitItem(ItemIdSnakValue $item) {
789
+		switch (true) {
790 790
 			case $item->isValue():
791
-				$unit = $this->parseUnitParameter( $item->getItemId() );
791
+				$unit = $this->parseUnitParameter($item->getItemId());
792 792
 				return new UnitsParameter(
793
-					[ $item->getItemId() ],
794
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
793
+					[$item->getItemId()],
794
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
795 795
 					false
796 796
 				);
797 797
 			case $item->isSomeValue():
798
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
798
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
799 799
 				throw new ConstraintParameterException(
800
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
801
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
800
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
801
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
802 802
 				);
803 803
 			case $item->isNoValue():
804
-				return new UnitsParameter( [], [], true );
804
+				return new UnitsParameter([], [], true);
805 805
 		}
806 806
 	}
807 807
 
@@ -811,36 +811,36 @@  discard block
 block discarded – undo
811 811
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
812 812
 	 * @return UnitsParameter
813 813
 	 */
814
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
815
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
814
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
815
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
816 816
 		$unitItems = [];
817 817
 		$unitQuantities = [];
818 818
 		$unitlessAllowed = false;
819 819
 
820
-		foreach ( $items as $item ) {
821
-			$unit = $this->parseUnitItem( $item );
822
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
823
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
820
+		foreach ($items as $item) {
821
+			$unit = $this->parseUnitItem($item);
822
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
823
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
824 824
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
825 825
 		}
826 826
 
827
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
827
+		if ($unitQuantities === [] && !$unitlessAllowed) {
828 828
 			throw new LogicException(
829 829
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
830 830
 			);
831 831
 		}
832 832
 
833
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
833
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
834 834
 	}
835 835
 
836 836
 	private function getEntityTypeMapping(): array {
837 837
 		return [
838
-			$this->config->get( 'WBQualityConstraintsWikibaseItemId' ) => 'item',
839
-			$this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) => 'property',
840
-			$this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) => 'lexeme',
841
-			$this->config->get( 'WBQualityConstraintsWikibaseFormId' ) => 'form',
842
-			$this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) => 'sense',
843
-			$this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) => 'mediainfo',
838
+			$this->config->get('WBQualityConstraintsWikibaseItemId') => 'item',
839
+			$this->config->get('WBQualityConstraintsWikibasePropertyId') => 'property',
840
+			$this->config->get('WBQualityConstraintsWikibaseLexemeId') => 'lexeme',
841
+			$this->config->get('WBQualityConstraintsWikibaseFormId') => 'form',
842
+			$this->config->get('WBQualityConstraintsWikibaseSenseId') => 'sense',
843
+			$this->config->get('WBQualityConstraintsWikibaseMediaInfoId') => 'mediainfo',
844 844
 		];
845 845
 	}
846 846
 
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
851 851
 	 * @return EntityTypesParameter
852 852
 	 */
853
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
853
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
854 854
 		$entityTypes = [];
855 855
 		$entityTypeItemIds = [];
856
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
856
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
857 857
 		$itemIds = $this->parseItemIdsParameter(
858 858
 			$constraintParameters,
859 859
 			$constraintTypeItemId,
@@ -862,22 +862,22 @@  discard block
 block discarded – undo
862 862
 		);
863 863
 
864 864
 		$mapping = $this->getEntityTypeMapping();
865
-		foreach ( $itemIds as $itemId ) {
866
-			$entityType = $this->mapItemId( $itemId, $mapping, $parameterId );
865
+		foreach ($itemIds as $itemId) {
866
+			$entityType = $this->mapItemId($itemId, $mapping, $parameterId);
867 867
 			$entityTypes[] = $entityType;
868 868
 			$entityTypeItemIds[] = $itemId;
869 869
 		}
870 870
 
871
-		if ( empty( $entityTypes ) ) {
871
+		if (empty($entityTypes)) {
872 872
 			// @codeCoverageIgnoreStart
873 873
 			throw new LogicException(
874
-				'The "entity types" parameter is required, ' .
874
+				'The "entity types" parameter is required, '.
875 875
 				'and yet we seem to be missing any allowed entity type'
876 876
 			);
877 877
 			// @codeCoverageIgnoreEnd
878 878
 		}
879 879
 
880
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
880
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
881 881
 	}
882 882
 
883 883
 	/**
@@ -885,18 +885,18 @@  discard block
 block discarded – undo
885 885
 	 * @throws ConstraintParameterException if the parameter is invalid
886 886
 	 * @return PropertyId[]
887 887
 	 */
888
-	public function parseSeparatorsParameter( array $constraintParameters ) {
889
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
888
+	public function parseSeparatorsParameter(array $constraintParameters) {
889
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
890 890
 
891
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
891
+		if (!array_key_exists($separatorId, $constraintParameters)) {
892 892
 			return [];
893 893
 		}
894 894
 
895 895
 		$parameters = $constraintParameters[$separatorId];
896 896
 		$separators = [];
897 897
 
898
-		foreach ( $parameters as $parameter ) {
899
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
898
+		foreach ($parameters as $parameter) {
899
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
900 900
 		}
901 901
 
902 902
 		return $separators;
@@ -904,17 +904,17 @@  discard block
 block discarded – undo
904 904
 
905 905
 	private function getConstraintScopeContextTypeMapping(): array {
906 906
 		return [
907
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ) => Context::TYPE_STATEMENT,
908
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ) => Context::TYPE_QUALIFIER,
909
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ) => Context::TYPE_REFERENCE,
907
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId') => Context::TYPE_STATEMENT,
908
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId') => Context::TYPE_QUALIFIER,
909
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId') => Context::TYPE_REFERENCE,
910 910
 		];
911 911
 	}
912 912
 
913 913
 	private function getPropertyScopeContextTypeMapping(): array {
914 914
 		return [
915
-			$this->config->get( 'WBQualityConstraintsAsMainValueId' ) => Context::TYPE_STATEMENT,
916
-			$this->config->get( 'WBQualityConstraintsAsQualifiersId' ) => Context::TYPE_QUALIFIER,
917
-			$this->config->get( 'WBQualityConstraintsAsReferencesId' ) => Context::TYPE_REFERENCE,
915
+			$this->config->get('WBQualityConstraintsAsMainValueId') => Context::TYPE_STATEMENT,
916
+			$this->config->get('WBQualityConstraintsAsQualifiersId') => Context::TYPE_QUALIFIER,
917
+			$this->config->get('WBQualityConstraintsAsReferencesId') => Context::TYPE_REFERENCE,
918 918
 		];
919 919
 	}
920 920
 
@@ -924,9 +924,9 @@  discard block
 block discarded – undo
924 924
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
925 925
 	 * @return string[] list of Context::TYPE_* constants
926 926
 	 */
927
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
927
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
928 928
 		$contextTypes = [];
929
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
929
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
930 930
 		$itemIds = $this->parseItemIdsParameter(
931 931
 			$constraintParameters,
932 932
 			$constraintTypeItemId,
@@ -935,14 +935,14 @@  discard block
 block discarded – undo
935 935
 		);
936 936
 
937 937
 		$mapping = $this->getPropertyScopeContextTypeMapping();
938
-		foreach ( $itemIds as $itemId ) {
939
-			$contextTypes[] = $this->mapItemId( $itemId, $mapping, $parameterId );
938
+		foreach ($itemIds as $itemId) {
939
+			$contextTypes[] = $this->mapItemId($itemId, $mapping, $parameterId);
940 940
 		}
941 941
 
942
-		if ( empty( $contextTypes ) ) {
942
+		if (empty($contextTypes)) {
943 943
 			// @codeCoverageIgnoreStart
944 944
 			throw new LogicException(
945
-				'The "property scope" parameter is required, ' .
945
+				'The "property scope" parameter is required, '.
946 946
 				'and yet we seem to be missing any allowed scope'
947 947
 			);
948 948
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.