@@ -88,39 +88,39 @@ discard block |
||
88 | 88 | * @throws ConstraintParameterException |
89 | 89 | * @return CheckResult |
90 | 90 | */ |
91 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
92 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
93 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
91 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
92 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
93 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $parameters = []; |
97 | 97 | $constraintParameters = $constraint->getConstraintParameters(); |
98 | 98 | |
99 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
100 | - $parameters['property'] = [ $propertyId ]; |
|
99 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
100 | + $parameters['property'] = [$propertyId]; |
|
101 | 101 | |
102 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
102 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
103 | 103 | $parameters['items'] = $items; |
104 | 104 | |
105 | 105 | /** @var StatementList $statementList */ |
106 | 106 | $statementList = $context->getEntity() |
107 | 107 | ->getStatements() |
108 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
108 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
109 | 109 | |
110 | 110 | /* |
111 | 111 | * 'Conflicts with' can be defined with |
112 | 112 | * a) a property only |
113 | 113 | * b) a property and a number of items (each combination of property and item forming an individual claim) |
114 | 114 | */ |
115 | - if ( $items === [] ) { |
|
115 | + if ($items === []) { |
|
116 | 116 | $offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
117 | 117 | $statementList, |
118 | 118 | $propertyId |
119 | 119 | ); |
120 | - if ( $offendingStatement !== null ) { |
|
121 | - $message = ( new ViolationMessage( 'wbqc-violation-message-conflicts-with-property' ) ) |
|
122 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ) |
|
123 | - ->withEntityId( $propertyId, Role::PREDICATE ); |
|
120 | + if ($offendingStatement !== null) { |
|
121 | + $message = (new ViolationMessage('wbqc-violation-message-conflicts-with-property')) |
|
122 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY) |
|
123 | + ->withEntityId($propertyId, Role::PREDICATE); |
|
124 | 124 | $status = CheckResult::STATUS_VIOLATION; |
125 | 125 | } else { |
126 | 126 | $message = null; |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | $propertyId, |
133 | 133 | $items |
134 | 134 | ); |
135 | - if ( $offendingStatement !== null ) { |
|
136 | - $offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() ); |
|
137 | - $message = ( new ViolationMessage( 'wbqc-violation-message-conflicts-with-claim' ) ) |
|
138 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ) |
|
139 | - ->withEntityId( $propertyId, Role::PREDICATE ) |
|
140 | - ->withItemIdSnakValue( $offendingValue, Role::OBJECT ); |
|
135 | + if ($offendingStatement !== null) { |
|
136 | + $offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak()); |
|
137 | + $message = (new ViolationMessage('wbqc-violation-message-conflicts-with-claim')) |
|
138 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY) |
|
139 | + ->withEntityId($propertyId, Role::PREDICATE) |
|
140 | + ->withItemIdSnakValue($offendingValue, Role::OBJECT); |
|
141 | 141 | $status = CheckResult::STATUS_VIOLATION; |
142 | 142 | } else { |
143 | 143 | $message = null; |
@@ -145,20 +145,20 @@ discard block |
||
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
148 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
149 | 149 | } |
150 | 150 | |
151 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
151 | + public function checkConstraintParameters(Constraint $constraint) { |
|
152 | 152 | $constraintParameters = $constraint->getConstraintParameters(); |
153 | 153 | $exceptions = []; |
154 | 154 | try { |
155 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
156 | - } catch ( ConstraintParameterException $e ) { |
|
155 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
156 | + } catch (ConstraintParameterException $e) { |
|
157 | 157 | $exceptions[] = $e; |
158 | 158 | } |
159 | 159 | try { |
160 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
161 | - } catch ( ConstraintParameterException $e ) { |
|
160 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
161 | + } catch (ConstraintParameterException $e) { |
|
162 | 162 | $exceptions[] = $e; |
163 | 163 | } |
164 | 164 | return $exceptions; |