@@ 256-269 (lines=14) @@ | ||
253 | * @throws ConstraintParameterException if the parameter is invalid or missing |
|
254 | * @return PropertyId |
|
255 | */ |
|
256 | public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
257 | $this->checkError( $constraintParameters ); |
|
258 | $propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' ); |
|
259 | if ( !array_key_exists( $propertyId, $constraintParameters ) ) { |
|
260 | throw new ConstraintParameterException( |
|
261 | ( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) ) |
|
262 | ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
263 | ->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY ) |
|
264 | ); |
|
265 | } |
|
266 | ||
267 | $this->requireSingleParameter( $constraintParameters, $propertyId ); |
|
268 | return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId ); |
|
269 | } |
|
270 | ||
271 | private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) { |
|
272 | $dataValue = $snak->getDataValue(); |
|
@@ 535-548 (lines=14) @@ | ||
532 | * @throws ConstraintParameterException if the parameter is invalid or missing |
|
533 | * @return string |
|
534 | */ |
|
535 | public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
536 | $this->checkError( $constraintParameters ); |
|
537 | $formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' ); |
|
538 | if ( !array_key_exists( $formatId, $constraintParameters ) ) { |
|
539 | throw new ConstraintParameterException( |
|
540 | ( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) ) |
|
541 | ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
542 | ->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY ) |
|
543 | ); |
|
544 | } |
|
545 | ||
546 | $this->requireSingleParameter( $constraintParameters, $formatId ); |
|
547 | return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId ); |
|
548 | } |
|
549 | ||
550 | /** |
|
551 | * @param array $constraintParameters see {@link \WikibaseQuality\Constraint::getConstraintParameters()} |