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