Code Duplication    Length = 14-14 lines in 2 locations

src/ConstraintCheck/Helper/ConstraintParameterParser.php 2 locations

@@ 246-259 (lines=14) @@
243
	 * @throws ConstraintParameterException if the parameter is invalid or missing
244
	 * @return PropertyId
245
	 */
246
	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
247
		$this->checkError( $constraintParameters );
248
		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
249
		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
250
			throw new ConstraintParameterException(
251
				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
252
					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
253
					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
254
			);
255
		}
256
257
		$this->requireSingleParameter( $constraintParameters, $propertyId );
258
		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
259
	}
260
261
	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
262
		$dataValue = $snak->getDataValue();
@@ 525-538 (lines=14) @@
522
	 * @throws ConstraintParameterException if the parameter is invalid or missing
523
	 * @return string
524
	 */
525
	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
526
		$this->checkError( $constraintParameters );
527
		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
528
		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
529
			throw new ConstraintParameterException(
530
				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
531
					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
532
					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
533
			);
534
		}
535
536
		$this->requireSingleParameter( $constraintParameters, $formatId );
537
		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
538
	}
539
540
	/**
541
	 * @param array $constraintParameters see {@link \WikibaseQuality\Constraint::getConstraintParameters()}