@@ -38,23 +38,23 @@ discard block |
||
38 | 38 | $this->dataValueFactory = $dataValueFactory; |
39 | 39 | } |
40 | 40 | |
41 | - public function unabbreviateViolationMessageKey( $messageKeySuffix ) { |
|
42 | - return ViolationMessage::MESSAGE_KEY_PREFIX . $messageKeySuffix; |
|
41 | + public function unabbreviateViolationMessageKey($messageKeySuffix) { |
|
42 | + return ViolationMessage::MESSAGE_KEY_PREFIX.$messageKeySuffix; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @param array $serialization |
47 | 47 | * @return ViolationMessage |
48 | 48 | */ |
49 | - public function deserialize( $serialization ) { |
|
50 | - Assert::parameterType( 'array', $serialization, '$serialization' ); |
|
49 | + public function deserialize($serialization) { |
|
50 | + Assert::parameterType('array', $serialization, '$serialization'); |
|
51 | 51 | |
52 | 52 | $message = new ViolationMessage( |
53 | - $this->unabbreviateViolationMessageKey( $serialization['k'] ) |
|
53 | + $this->unabbreviateViolationMessageKey($serialization['k']) |
|
54 | 54 | ); |
55 | 55 | |
56 | - foreach ( $serialization['a'] as $serializedArgument ) { |
|
57 | - $message = $this->deserializeArgument( $message, $serializedArgument ); |
|
56 | + foreach ($serialization['a'] as $serializedArgument) { |
|
57 | + $message = $this->deserializeArgument($message, $serializedArgument); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $message; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array $serializedArgument [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, 'r' => $role ] |
66 | 66 | * @return ViolationMessage $message with the deserialized argument appended |
67 | 67 | */ |
68 | - private function deserializeArgument( ViolationMessage $message, array $serializedArgument ) { |
|
68 | + private function deserializeArgument(ViolationMessage $message, array $serializedArgument) { |
|
69 | 69 | $methods = [ |
70 | 70 | ViolationMessage::TYPE_ENTITY_ID => 'deserializeEntityId', |
71 | 71 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'deserializeEntityIdList', |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | $serializedValue = $serializedArgument['v']; |
83 | 83 | $role = $serializedArgument['r']; |
84 | 84 | |
85 | - if ( array_key_exists( $type, $methods ) ) { |
|
85 | + if (array_key_exists($type, $methods)) { |
|
86 | 86 | $method = $methods[$type]; |
87 | - $value = $this->$method( $serializedValue ); |
|
87 | + $value = $this->$method($serializedValue); |
|
88 | 88 | } else { |
89 | 89 | throw new InvalidArgumentException( |
90 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
90 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | - return $message->withArgument( $type, $role, $value ); |
|
94 | + return $message->withArgument($type, $role, $value); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @param string $string any value that shall simply be deserialized into itself |
99 | 99 | * @return string that same value, unchanged |
100 | 100 | */ |
101 | - private function deserializeStringByIdentity( $string ) { |
|
101 | + private function deserializeStringByIdentity($string) { |
|
102 | 102 | return $string; |
103 | 103 | } |
104 | 104 | |
@@ -106,30 +106,30 @@ discard block |
||
106 | 106 | * @param string $entityIdSerialization entity ID serialization |
107 | 107 | * @return EntityId |
108 | 108 | */ |
109 | - private function deserializeEntityId( $entityIdSerialization ) { |
|
110 | - return $this->entityIdParser->parse( $entityIdSerialization ); |
|
109 | + private function deserializeEntityId($entityIdSerialization) { |
|
110 | + return $this->entityIdParser->parse($entityIdSerialization); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @param string[] $entityIdSerializations entity ID serializations |
115 | 115 | * @return EntityId[] |
116 | 116 | */ |
117 | - private function deserializeEntityIdList( array $entityIdSerializations ) { |
|
118 | - return array_map( [ $this, 'deserializeEntityId' ], $entityIdSerializations ); |
|
117 | + private function deserializeEntityIdList(array $entityIdSerializations) { |
|
118 | + return array_map([$this, 'deserializeEntityId'], $entityIdSerializations); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @param string $valueSerialization entity ID serialization, '::somevalue' or '::novalue' |
123 | 123 | * @return ItemIdSnakValue |
124 | 124 | */ |
125 | - private function deserializeItemIdSnakValue( $valueSerialization ) { |
|
126 | - switch ( $valueSerialization ) { |
|
125 | + private function deserializeItemIdSnakValue($valueSerialization) { |
|
126 | + switch ($valueSerialization) { |
|
127 | 127 | case '::somevalue': |
128 | 128 | return ItemIdSnakValue::someValue(); |
129 | 129 | case '::novalue': |
130 | 130 | return ItemIdSnakValue::noValue(); |
131 | 131 | default: |
132 | - return ItemIdSnakValue::fromItemId( $this->deserializeEntityId( $valueSerialization ) ); |
|
132 | + return ItemIdSnakValue::fromItemId($this->deserializeEntityId($valueSerialization)); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | * @param string[] $valueSerializations entity ID serializations, '::somevalue's or '::novalue's |
138 | 138 | * @return ItemIdSnakValue[] |
139 | 139 | */ |
140 | - private function deserializeItemIdSnakValueList( $valueSerializations ) { |
|
141 | - return array_map( [ $this, 'deserializeItemIdSnakValue' ], $valueSerializations ); |
|
140 | + private function deserializeItemIdSnakValueList($valueSerializations) { |
|
141 | + return array_map([$this, 'deserializeItemIdSnakValue'], $valueSerializations); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * @param array $dataValueSerialization the data value in array form |
146 | 146 | * @return DataValue |
147 | 147 | */ |
148 | - private function deserializeDataValue( array $dataValueSerialization ) { |
|
149 | - return $this->dataValueFactory->newFromArray( $dataValueSerialization ); |
|
148 | + private function deserializeDataValue(array $dataValueSerialization) { |
|
149 | + return $this->dataValueFactory->newFromArray($dataValueSerialization); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * @param string $scopeAbbreviation |
154 | 154 | * @return string one of the Context::TYPE_* constants |
155 | 155 | */ |
156 | - private function deserializeConstraintScope( $scopeAbbreviation ) { |
|
157 | - switch ( $scopeAbbreviation ) { |
|
156 | + private function deserializeConstraintScope($scopeAbbreviation) { |
|
157 | + switch ($scopeAbbreviation) { |
|
158 | 158 | case 's': |
159 | 159 | return Context::TYPE_STATEMENT; |
160 | 160 | case 'q': |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | default: |
165 | 165 | // @codeCoverageIgnoreStart |
166 | 166 | throw new LogicException( |
167 | - 'Unknown constraint scope abbreviation ' . $scopeAbbreviation |
|
167 | + 'Unknown constraint scope abbreviation '.$scopeAbbreviation |
|
168 | 168 | ); |
169 | 169 | // @codeCoverageIgnoreEnd |
170 | 170 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @param string[] $scopeAbbreviations |
175 | 175 | * @return string[] Context::TYPE_* constants |
176 | 176 | */ |
177 | - private function deserializeConstraintScopeList( array $scopeAbbreviations ) { |
|
178 | - return array_map( [ $this, 'deserializeConstraintScope' ], $scopeAbbreviations ); |
|
177 | + private function deserializeConstraintScopeList(array $scopeAbbreviations) { |
|
178 | + return array_map([$this, 'deserializeConstraintScope'], $scopeAbbreviations); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | } |
@@ -18,26 +18,26 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class ViolationMessageSerializer implements Serializer { |
20 | 20 | |
21 | - private function abbreviateViolationMessageKey( $fullMessageKey ) { |
|
22 | - return substr( $fullMessageKey, strlen( ViolationMessage::MESSAGE_KEY_PREFIX ) ); |
|
21 | + private function abbreviateViolationMessageKey($fullMessageKey) { |
|
22 | + return substr($fullMessageKey, strlen(ViolationMessage::MESSAGE_KEY_PREFIX)); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @param ViolationMessage $object |
27 | 27 | * @return array |
28 | 28 | */ |
29 | - public function serialize( $object ) { |
|
29 | + public function serialize($object) { |
|
30 | 30 | /** @var ViolationMessage $object */ |
31 | - Assert::parameterType( ViolationMessage::class, $object, '$object' ); |
|
31 | + Assert::parameterType(ViolationMessage::class, $object, '$object'); |
|
32 | 32 | |
33 | 33 | $arguments = $object->getArguments(); |
34 | 34 | $serializedArguments = []; |
35 | - foreach ( $arguments as $argument ) { |
|
36 | - $serializedArguments[] = $this->serializeArgument( $argument ); |
|
35 | + foreach ($arguments as $argument) { |
|
36 | + $serializedArguments[] = $this->serializeArgument($argument); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return [ |
40 | - 'k' => $this->abbreviateViolationMessageKey( $object->getMessageKey() ), |
|
40 | + 'k' => $this->abbreviateViolationMessageKey($object->getMessageKey()), |
|
41 | 41 | 'a' => $serializedArguments, |
42 | 42 | ]; |
43 | 43 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param array $argument element of ViolationMessage::getArguments() |
47 | 47 | * @return array [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, 'r' => $role ] |
48 | 48 | */ |
49 | - private function serializeArgument( array $argument ) { |
|
49 | + private function serializeArgument(array $argument) { |
|
50 | 50 | $methods = [ |
51 | 51 | ViolationMessage::TYPE_ENTITY_ID => 'serializeEntityId', |
52 | 52 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'serializeEntityIdList', |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | $value = $argument['value']; |
64 | 64 | $role = $argument['role']; |
65 | 65 | |
66 | - if ( array_key_exists( $type, $methods ) ) { |
|
66 | + if (array_key_exists($type, $methods)) { |
|
67 | 67 | $method = $methods[$type]; |
68 | - $serializedValue = $this->$method( $value ); |
|
68 | + $serializedValue = $this->$method($value); |
|
69 | 69 | } else { |
70 | 70 | throw new InvalidArgumentException( |
71 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
71 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string $string any value that shall simply be serialized to itself |
86 | 86 | * @return string that same value, unchanged |
87 | 87 | */ |
88 | - private function serializeStringByIdentity( $string ) { |
|
88 | + private function serializeStringByIdentity($string) { |
|
89 | 89 | return $string; |
90 | 90 | } |
91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param EntityId $entityId |
94 | 94 | * @return string entity ID serialization |
95 | 95 | */ |
96 | - private function serializeEntityId( EntityId $entityId ) { |
|
96 | + private function serializeEntityId(EntityId $entityId) { |
|
97 | 97 | return $entityId->getSerialization(); |
98 | 98 | } |
99 | 99 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * @param EntityId[] $entityIdList |
102 | 102 | * @return string[] entity ID serializations |
103 | 103 | */ |
104 | - private function serializeEntityIdList( array $entityIdList ) { |
|
105 | - return array_map( [ $this, 'serializeEntityId' ], $entityIdList ); |
|
104 | + private function serializeEntityIdList(array $entityIdList) { |
|
105 | + return array_map([$this, 'serializeEntityId'], $entityIdList); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * @return string entity ID serialization, '::somevalue', or '::novalue' |
111 | 111 | * (according to EntityId::PATTERN, entity ID serializations can never begin with two colons) |
112 | 112 | */ |
113 | - private function serializeItemIdSnakValue( ItemIdSnakValue $value ) { |
|
114 | - switch ( true ) { |
|
113 | + private function serializeItemIdSnakValue(ItemIdSnakValue $value) { |
|
114 | + switch (true) { |
|
115 | 115 | case $value->isValue(): |
116 | - return $this->serializeEntityId( $value->getItemId() ); |
|
116 | + return $this->serializeEntityId($value->getItemId()); |
|
117 | 117 | case $value->isSomeValue(): |
118 | 118 | return '::somevalue'; |
119 | 119 | case $value->isNoValue(): |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | * @param ItemIdSnakValue[] $valueList |
132 | 132 | * @return string[] array of entity ID serializations, '::somevalue's or '::novalue's |
133 | 133 | */ |
134 | - private function serializeItemIdSnakValueList( array $valueList ) { |
|
135 | - return array_map( [ $this, 'serializeItemIdSnakValue' ], $valueList ); |
|
134 | + private function serializeItemIdSnakValueList(array $valueList) { |
|
135 | + return array_map([$this, 'serializeItemIdSnakValue'], $valueList); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @param DataValue $dataValue |
140 | 140 | * @return array the data value in array form |
141 | 141 | */ |
142 | - private function serializeDataValue( DataValue $dataValue ) { |
|
142 | + private function serializeDataValue(DataValue $dataValue) { |
|
143 | 143 | return $dataValue->toArray(); |
144 | 144 | } |
145 | 145 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @param string $scope one of the Context::TYPE_* constants |
148 | 148 | * @return string the abbreviated scope |
149 | 149 | */ |
150 | - private function serializeConstraintScope( $scope ) { |
|
151 | - switch ( $scope ) { |
|
150 | + private function serializeConstraintScope($scope) { |
|
151 | + switch ($scope) { |
|
152 | 152 | case Context::TYPE_STATEMENT: |
153 | 153 | return 's'; |
154 | 154 | case Context::TYPE_QUALIFIER: |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | default: |
159 | 159 | // @codeCoverageIgnoreStart |
160 | 160 | throw new LogicException( |
161 | - 'Unknown constraint scope ' . $scope |
|
161 | + 'Unknown constraint scope '.$scope |
|
162 | 162 | ); |
163 | 163 | // @codeCoverageIgnoreEnd |
164 | 164 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param string[] $scopeList Context::TYPE_* constants |
169 | 169 | * @return string[] abbreviated scopes |
170 | 170 | */ |
171 | - private function serializeConstraintScopeList( array $scopeList ) { |
|
172 | - return array_map( [ $this, 'serializeConstraintScope' ], $scopeList ); |
|
171 | + private function serializeConstraintScopeList(array $scopeList) { |
|
172 | + return array_map([$this, 'serializeConstraintScope'], $scopeList); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | } |