@@ -13,23 +13,23 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class ViolationMessageDeserializer implements Deserializer { |
15 | 15 | |
16 | - public function unabbreviateViolationMessageKey( $messageKeySuffix ) { |
|
17 | - return ViolationMessage::MESSAGE_KEY_PREFIX . $messageKeySuffix; |
|
16 | + public function unabbreviateViolationMessageKey($messageKeySuffix) { |
|
17 | + return ViolationMessage::MESSAGE_KEY_PREFIX.$messageKeySuffix; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param array $serialization |
22 | 22 | * @return ViolationMessage |
23 | 23 | */ |
24 | - public function deserialize( $serialization ) { |
|
25 | - Assert::parameterType( 'array', $serialization, '$serialization' ); |
|
24 | + public function deserialize($serialization) { |
|
25 | + Assert::parameterType('array', $serialization, '$serialization'); |
|
26 | 26 | |
27 | 27 | $message = new ViolationMessage( |
28 | - $this->unabbreviateViolationMessageKey( $serialization['k'] ) |
|
28 | + $this->unabbreviateViolationMessageKey($serialization['k']) |
|
29 | 29 | ); |
30 | 30 | |
31 | - foreach ( $serialization['a'] as $serializedArgument ) { |
|
32 | - $message = $this->deserializeArgument( $message, $serializedArgument ); |
|
31 | + foreach ($serialization['a'] as $serializedArgument) { |
|
32 | + $message = $this->deserializeArgument($message, $serializedArgument); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $message; |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * 'r' => $role, (optional) 'a' => $alternativeMessageKey ] |
42 | 42 | * @return ViolationMessage $message with the deserialized argument appended |
43 | 43 | */ |
44 | - private function deserializeArgument( ViolationMessage $message, array $serializedArgument ) { |
|
44 | + private function deserializeArgument(ViolationMessage $message, array $serializedArgument) { |
|
45 | 45 | $methods = [ |
46 | 46 | ]; |
47 | 47 | |
48 | 48 | $type = $serializedArgument['t']; |
49 | 49 | $serializedValue = $serializedArgument['v']; |
50 | 50 | $role = $serializedArgument['r']; |
51 | - if ( array_key_exists( 'a', $serializedArgument ) ) { |
|
51 | + if (array_key_exists('a', $serializedArgument)) { |
|
52 | 52 | $alternativeMessageKey = $this->unabbreviateViolationMessageKey( |
53 | 53 | $serializedArgument['a'] |
54 | 54 | ); |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | $alternativeMessageKey = null; |
57 | 57 | } |
58 | 58 | |
59 | - if ( array_key_exists( $type, $methods ) ) { |
|
59 | + if (array_key_exists($type, $methods)) { |
|
60 | 60 | $method = $methods[$type]; |
61 | - $value = $this->$method( $serializedValue ); |
|
61 | + $value = $this->$method($serializedValue); |
|
62 | 62 | } else { |
63 | 63 | throw new InvalidArgumentException( |
64 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
64 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
68 | - return $message->withArgument( $type, $role, $value, $alternativeMessageKey ); |
|
68 | + return $message->withArgument($type, $role, $value, $alternativeMessageKey); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | public function __construct( |
104 | 104 | $messageKey |
105 | 105 | ) { |
106 | - if ( strpos( $messageKey, self::MESSAGE_KEY_PREFIX ) !== 0 ) { |
|
106 | + if (strpos($messageKey, self::MESSAGE_KEY_PREFIX) !== 0) { |
|
107 | 107 | throw new InvalidArgumentException( |
108 | - 'ViolationMessage key ⧼' . |
|
109 | - $messageKey . |
|
110 | - '⧽ should start with "' . |
|
111 | - self::MESSAGE_KEY_PREFIX . |
|
108 | + 'ViolationMessage key ⧼'. |
|
109 | + $messageKey. |
|
110 | + '⧽ should start with "'. |
|
111 | + self::MESSAGE_KEY_PREFIX. |
|
112 | 112 | '".' |
113 | 113 | ); |
114 | 114 | } |
115 | 115 | |
116 | - $this->messageKeySuffix = substr( $messageKey, strlen( self::MESSAGE_KEY_PREFIX ) ); |
|
116 | + $this->messageKeySuffix = substr($messageKey, strlen(self::MESSAGE_KEY_PREFIX)); |
|
117 | 117 | $this->arguments = []; |
118 | 118 | } |
119 | 119 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @return string |
123 | 123 | */ |
124 | 124 | public function getMessageKey() { |
125 | - return self::MESSAGE_KEY_PREFIX . $this->messageKeySuffix; |
|
125 | + return self::MESSAGE_KEY_PREFIX.$this->messageKeySuffix; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param mixed $value the value, which should match the $type |
143 | 143 | * @return ViolationMessage |
144 | 144 | */ |
145 | - public function withArgument( $type, $role, $value ) { |
|
145 | + public function withArgument($type, $role, $value) { |
|
146 | 146 | $ret = clone $this; |
147 | - $ret->arguments[] = [ 'type' => $type, 'role' => $role, 'value' => $value ]; |
|
147 | + $ret->arguments[] = ['type' => $type, 'role' => $role, 'value' => $value]; |
|
148 | 148 | return $ret; |
149 | 149 | } |
150 | 150 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @param string|null $role one of the Role::* constants |
157 | 157 | * @return ViolationMessage |
158 | 158 | */ |
159 | - public function withEntityId( EntityId $entityId, $role = null ) { |
|
160 | - return $this->withArgument( self::TYPE_ENTITY_ID, $role, $entityId ); |
|
159 | + public function withEntityId(EntityId $entityId, $role = null) { |
|
160 | + return $this->withArgument(self::TYPE_ENTITY_ID, $role, $entityId); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @param string|null $role one of the Role::* constants |
175 | 175 | * @return ViolationMessage |
176 | 176 | */ |
177 | - public function withEntityIdList( array $entityIdList, $role = null ) { |
|
178 | - return $this->withArgument( self::TYPE_ENTITY_ID_LIST, $role, $entityIdList ); |
|
177 | + public function withEntityIdList(array $entityIdList, $role = null) { |
|
178 | + return $this->withArgument(self::TYPE_ENTITY_ID_LIST, $role, $entityIdList); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param string|null $role one of the Role::* constants |
187 | 187 | * @return ViolationMessage |
188 | 188 | */ |
189 | - public function withItemIdSnakValue( ItemIdSnakValue $value, $role = null ) { |
|
190 | - return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value ); |
|
189 | + public function withItemIdSnakValue(ItemIdSnakValue $value, $role = null) { |
|
190 | + return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * @param string|null $role one of the Role::* constants |
205 | 205 | * @return ViolationMessage |
206 | 206 | */ |
207 | - public function withItemIdSnakValueList( array $valueList, $role = null ) { |
|
208 | - return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList ); |
|
207 | + public function withItemIdSnakValueList(array $valueList, $role = null) { |
|
208 | + return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | * @param string|null $role one of the Role::* constants |
217 | 217 | * @return ViolationMessage |
218 | 218 | */ |
219 | - public function withDataValue( DataValue $dataValue, $role = null ) { |
|
220 | - return $this->withArgument( self::TYPE_DATA_VALUE, $role, $dataValue ); |
|
219 | + public function withDataValue(DataValue $dataValue, $role = null) { |
|
220 | + return $this->withArgument(self::TYPE_DATA_VALUE, $role, $dataValue); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * @param string|null $role one of the Role::* constants |
233 | 233 | * @return ViolationMessage |
234 | 234 | */ |
235 | - public function withDataValueType( $dataValueType, $role = null ) { |
|
236 | - return $this->withArgument( self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType ); |
|
235 | + public function withDataValueType($dataValueType, $role = null) { |
|
236 | + return $this->withArgument(self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param string|null $role one of the Role::* constants |
245 | 245 | * @return ViolationMessage |
246 | 246 | */ |
247 | - public function withInlineCode( $code, $role = null ) { |
|
248 | - return $this->withArgument( self::TYPE_INLINE_CODE, $role, $code ); |
|
247 | + public function withInlineCode($code, $role = null) { |
|
248 | + return $this->withArgument(self::TYPE_INLINE_CODE, $role, $code); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | * @param string|null $role one of the Role::* constants |
257 | 257 | * @return ViolationMessage |
258 | 258 | */ |
259 | - public function withConstraintScope( $scope, $role = null ) { |
|
260 | - return $this->withArgument( self::TYPE_CONSTRAINT_SCOPE, $role, $scope ); |
|
259 | + public function withConstraintScope($scope, $role = null) { |
|
260 | + return $this->withArgument(self::TYPE_CONSTRAINT_SCOPE, $role, $scope); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param string|null $role one of the Role::* constants |
269 | 269 | * @return ViolationMessage |
270 | 270 | */ |
271 | - public function withConstraintScopeList( array $scopeList, $role = null ) { |
|
272 | - return $this->withArgument( self::TYPE_CONSTRAINT_SCOPE_LIST, $role, $scopeList ); |
|
271 | + public function withConstraintScopeList(array $scopeList, $role = null) { |
|
272 | + return $this->withArgument(self::TYPE_CONSTRAINT_SCOPE_LIST, $role, $scopeList); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * @param string $languageCode |
285 | 285 | * @return ViolationMessage |
286 | 286 | */ |
287 | - public function withLanguage( $languageCode ) { |
|
288 | - return $this->withArgument( self::TYPE_LANGUAGE, null, $languageCode ); |
|
287 | + public function withLanguage($languageCode) { |
|
288 | + return $this->withArgument(self::TYPE_LANGUAGE, null, $languageCode); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | } |