Code Duplication    Length = 6-7 lines in 7 locations

src/ConstraintCheck/Checker/AllowedUnitsChecker.php 1 location

@@ 94-99 (lines=6) @@
91
		}
92
93
		$dataValue = $snak->getDataValue();
94
		if ( !$dataValue instanceof UnboundedQuantityValue ) {
95
			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
96
				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
97
				->withDataValueType( 'quantity' );
98
			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
99
		}
100
101
		if ( $dataValue->getUnit() === '1' ) {
102
			return $this->checkUnitless( $context, $constraint, $unitsParameter, $snak );

src/ConstraintCheck/Checker/CommonsLinkChecker.php 1 location

@@ 123-128 (lines=6) @@
120
		 *   type of $dataValue for properties with 'Commons link' constraint has to be 'string'
121
		 *   parameter $namespace can be null, works for commons galleries
122
		 */
123
		if ( $dataValue->getType() !== 'string' ) {
124
			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
125
				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
126
				->withDataValueType( 'string' );
127
			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
128
		}
129
130
		$commonsLink = $dataValue->getValue();
131

src/ConstraintCheck/Checker/InverseChecker.php 1 location

@@ 110-115 (lines=6) @@
107
		 * error handling:
108
		 *   type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid'
109
		 */
110
		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
111
			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
112
				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
113
				->withDataValueType( 'wikibase-entityid' );
114
			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
115
		}
116
		/** @var EntityIdValue $dataValue */
117
118
		$targetEntityId = $dataValue->getEntityId();

src/ConstraintCheck/Checker/SymmetricChecker.php 1 location

@@ 97-102 (lines=6) @@
94
		 * error handling:
95
		 *   type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid'
96
		 */
97
		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
98
			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
99
				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
100
				->withDataValueType( 'wikibase-entityid' );
101
			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
102
		}
103
		/** @var EntityIdValue $dataValue */
104
105
		$targetEntityId = $dataValue->getEntityId();

src/ConstraintCheck/Checker/TargetRequiredClaimChecker.php 1 location

@@ 111-116 (lines=6) @@
108
		 * error handling:
109
		 *   type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid'
110
		 */
111
		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
112
			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
113
				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
114
				->withDataValueType( 'wikibase-entityid' );
115
			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
116
		}
117
		/** @var EntityIdValue $dataValue */
118
119
		$targetEntityId = $dataValue->getEntityId();

src/ConstraintCheck/Checker/ValueTypeChecker.php 1 location

@@ 132-137 (lines=6) @@
129
		 * error handling:
130
		 *   type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid'
131
		 */
132
		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
133
			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
134
				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
135
				->withDataValueType( 'wikibase-entityid' );
136
			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
137
		}
138
		/** @var EntityIdValue $dataValue */
139
140
		$item = $this->entityLookup->getEntity( $dataValue->getEntityId() );

src/ConstraintCheck/Checker/ContemporaryChecker.php 1 location

@@ 100-106 (lines=7) @@
97
		if ( !$snak instanceof PropertyValueSnak ) {
98
			// nothing to check
99
			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
100
		} elseif ( $snak->getDataValue()->getType() !== 'wikibase-entityid' ) {
101
			// wrong data type
102
			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
103
				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
104
				->withDataValueType( 'wikibase-entityid' );
105
			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
106
		}
107
		/** @var EntityId $subjectId */
108
		$subjectId = $context->getEntity()->getId();
109
		/** @var EntityId $objectId */