@@ -26,23 +26,23 @@ discard block |
||
26 | 26 | $this->entityIdParser = $entityIdParser; |
27 | 27 | } |
28 | 28 | |
29 | - public function unabbreviateViolationMessageKey( $messageKeySuffix ) { |
|
30 | - return ViolationMessage::MESSAGE_KEY_PREFIX . $messageKeySuffix; |
|
29 | + public function unabbreviateViolationMessageKey($messageKeySuffix) { |
|
30 | + return ViolationMessage::MESSAGE_KEY_PREFIX.$messageKeySuffix; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @param array $serialization |
35 | 35 | * @return ViolationMessage |
36 | 36 | */ |
37 | - public function deserialize( $serialization ) { |
|
38 | - Assert::parameterType( 'array', $serialization, '$serialization' ); |
|
37 | + public function deserialize($serialization) { |
|
38 | + Assert::parameterType('array', $serialization, '$serialization'); |
|
39 | 39 | |
40 | 40 | $message = new ViolationMessage( |
41 | - $this->unabbreviateViolationMessageKey( $serialization['k'] ) |
|
41 | + $this->unabbreviateViolationMessageKey($serialization['k']) |
|
42 | 42 | ); |
43 | 43 | |
44 | - foreach ( $serialization['a'] as $serializedArgument ) { |
|
45 | - $message = $this->deserializeArgument( $message, $serializedArgument ); |
|
44 | + foreach ($serialization['a'] as $serializedArgument) { |
|
45 | + $message = $this->deserializeArgument($message, $serializedArgument); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return $message; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * 'r' => $role, (optional) 'a' => $alternativeMessageKey ] |
55 | 55 | * @return ViolationMessage $message with the deserialized argument appended |
56 | 56 | */ |
57 | - private function deserializeArgument( ViolationMessage $message, array $serializedArgument ) { |
|
57 | + private function deserializeArgument(ViolationMessage $message, array $serializedArgument) { |
|
58 | 58 | $methods = [ |
59 | 59 | ViolationMessage::TYPE_ENTITY_ID => 'deserializeEntityId', |
60 | 60 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'deserializeEntityIdList', |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $type = $serializedArgument['t']; |
64 | 64 | $serializedValue = $serializedArgument['v']; |
65 | 65 | $role = $serializedArgument['r']; |
66 | - if ( array_key_exists( 'a', $serializedArgument ) ) { |
|
66 | + if (array_key_exists('a', $serializedArgument)) { |
|
67 | 67 | $alternativeMessageKey = $this->unabbreviateViolationMessageKey( |
68 | 68 | $serializedArgument['a'] |
69 | 69 | ); |
@@ -71,32 +71,32 @@ discard block |
||
71 | 71 | $alternativeMessageKey = null; |
72 | 72 | } |
73 | 73 | |
74 | - if ( array_key_exists( $type, $methods ) ) { |
|
74 | + if (array_key_exists($type, $methods)) { |
|
75 | 75 | $method = $methods[$type]; |
76 | - $value = $this->$method( $serializedValue ); |
|
76 | + $value = $this->$method($serializedValue); |
|
77 | 77 | } else { |
78 | 78 | throw new InvalidArgumentException( |
79 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
79 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
83 | - return $message->withArgument( $type, $role, $value, $alternativeMessageKey ); |
|
83 | + return $message->withArgument($type, $role, $value, $alternativeMessageKey); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | 87 | * @param string $entityIdSerialization entity ID serialization |
88 | 88 | * @return EntityId |
89 | 89 | */ |
90 | - private function deserializeEntityId( $entityIdSerialization ) { |
|
91 | - return $this->entityIdParser->parse( $entityIdSerialization ); |
|
90 | + private function deserializeEntityId($entityIdSerialization) { |
|
91 | + return $this->entityIdParser->parse($entityIdSerialization); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @param string[] $entityIdSerializations entity ID serializations |
96 | 96 | * @return EntityId[] |
97 | 97 | */ |
98 | - private function deserializeEntityIdList( array $entityIdSerializations ) { |
|
99 | - return array_map( [ $this, 'deserializeEntityId' ], $entityIdSerializations ); |
|
98 | + private function deserializeEntityIdList(array $entityIdSerializations) { |
|
99 | + return array_map([$this, 'deserializeEntityId'], $entityIdSerializations); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | } |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class ViolationMessageSerializer implements Serializer { |
16 | 16 | |
17 | - private function abbreviateViolationMessageKey( $fullMessageKey ) { |
|
18 | - return substr( $fullMessageKey, strlen( ViolationMessage::MESSAGE_KEY_PREFIX ) ); |
|
17 | + private function abbreviateViolationMessageKey($fullMessageKey) { |
|
18 | + return substr($fullMessageKey, strlen(ViolationMessage::MESSAGE_KEY_PREFIX)); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param ViolationMessage $object |
23 | 23 | * @return array |
24 | 24 | */ |
25 | - public function serialize( $object ) { |
|
25 | + public function serialize($object) { |
|
26 | 26 | /** @var ViolationMessage $object */ |
27 | - Assert::parameterType( ViolationMessage::class, $object, '$object' ); |
|
27 | + Assert::parameterType(ViolationMessage::class, $object, '$object'); |
|
28 | 28 | |
29 | 29 | $arguments = $object->getArguments(); |
30 | 30 | $serializedArguments = []; |
31 | - foreach ( $arguments as $argument ) { |
|
32 | - $serializedArguments[] = $this->serializeArgument( $argument ); |
|
31 | + foreach ($arguments as $argument) { |
|
32 | + $serializedArguments[] = $this->serializeArgument($argument); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return [ |
36 | - 'k' => $this->abbreviateViolationMessageKey( $object->getMessageKey() ), |
|
36 | + 'k' => $this->abbreviateViolationMessageKey($object->getMessageKey()), |
|
37 | 37 | 'a' => $serializedArguments, |
38 | 38 | ]; |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return array [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, |
44 | 44 | * 'r' => $role, (optional) 'a' => $alternativeMessageKey ] |
45 | 45 | */ |
46 | - private function serializeArgument( array $argument ) { |
|
46 | + private function serializeArgument(array $argument) { |
|
47 | 47 | $methods = [ |
48 | 48 | ViolationMessage::TYPE_ENTITY_ID => 'serializeEntityId', |
49 | 49 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'serializeEntityIdList', |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | $value = $argument['value']; |
54 | 54 | $role = $argument['role']; |
55 | 55 | |
56 | - if ( array_key_exists( $type, $methods ) ) { |
|
56 | + if (array_key_exists($type, $methods)) { |
|
57 | 57 | $method = $methods[$type]; |
58 | - $serializedValue = $this->$method( $value ); |
|
58 | + $serializedValue = $this->$method($value); |
|
59 | 59 | } else { |
60 | 60 | throw new InvalidArgumentException( |
61 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
61 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'r' => $role, |
69 | 69 | ]; |
70 | 70 | |
71 | - if ( array_key_exists( 'alternativeMessageKey', $argument ) ) { |
|
71 | + if (array_key_exists('alternativeMessageKey', $argument)) { |
|
72 | 72 | $serialized['a'] = $this->abbreviateViolationMessageKey( |
73 | 73 | $argument['alternativeMessageKey'] |
74 | 74 | ); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param EntityId $entityId |
82 | 82 | * @return string entity ID serialization |
83 | 83 | */ |
84 | - private function serializeEntityId( EntityId $entityId ) { |
|
84 | + private function serializeEntityId(EntityId $entityId) { |
|
85 | 85 | return $entityId->getSerialization(); |
86 | 86 | } |
87 | 87 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param EntityId[] $entityIdList |
90 | 90 | * @return string[] entity ID serializations |
91 | 91 | */ |
92 | - private function serializeEntityIdList( array $entityIdList ) { |
|
93 | - return array_map( [ $this, 'serializeEntityId' ], $entityIdList ); |
|
92 | + private function serializeEntityIdList(array $entityIdList) { |
|
93 | + return array_map([$this, 'serializeEntityId'], $entityIdList); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | } |