Code Duplication    Length = 20-26 lines in 2 locations

src/ConstraintCheck/Message/ViolationMessageRenderer.php 2 locations

@@ 327-352 (lines=26) @@
324
	 * @param string|null $role one of the Role::* constants
325
	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
326
	 */
327
	private function renderConstraintScope( $scope, $role ) {
328
		switch ( $scope ) {
329
			case Context::TYPE_STATEMENT:
330
				$itemId = $this->config->get(
331
					'WBQualityConstraintsConstraintCheckedOnMainValueId'
332
				);
333
				break;
334
			case Context::TYPE_QUALIFIER:
335
				$itemId = $this->config->get(
336
					'WBQualityConstraintsConstraintCheckedOnQualifiersId'
337
				);
338
				break;
339
			case Context::TYPE_REFERENCE:
340
				$itemId = $this->config->get(
341
					'WBQualityConstraintsConstraintCheckedOnReferencesId'
342
				);
343
				break;
344
			default:
345
				// callers should never let this happen, but if it does happen,
346
				// showing “unknown value” seems reasonable
347
				// @codeCoverageIgnoreStart
348
				return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
349
				// @codeCoverageIgnoreEnd
350
		}
351
		return $this->renderEntityId( new ItemId( $itemId ), $role );
352
	}
353
354
	/**
355
	 * @param string[] $text Context::TYPE_* constants
@@ 368-387 (lines=20) @@
365
	 * @param string|null $role one of the Role::* constants
366
	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
367
	 */
368
	private function renderPropertyScope( $scope, $role ) {
369
		switch ( $scope ) {
370
			case Context::TYPE_STATEMENT:
371
				$itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' );
372
				break;
373
			case Context::TYPE_QUALIFIER:
374
				$itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' );
375
				break;
376
			case Context::TYPE_REFERENCE:
377
				$itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' );
378
				break;
379
			default:
380
				// callers should never let this happen, but if it does happen,
381
				// showing “unknown value” seems reasonable
382
				// @codeCoverageIgnoreStart
383
				return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
384
				// @codeCoverageIgnoreEnd
385
		}
386
		return $this->renderEntityId( new ItemId( $itemId ), $role );
387
	}
388
389
	/**
390
	 * @param string[] $text Context::TYPE_* constants