Completed
Push — master ( b322cc...9e2687 )
by
unknown
05:14 queued 02:44
created
src/ConstraintCheck/Message/ViolationMessageSerializer.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,26 +18,26 @@  discard block
 block discarded – undo
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
 block discarded – undo
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',
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 		$value = $argument['value'];
65 65
 		$role = $argument['role'];
66 66
 
67
-		if ( array_key_exists( $type, $methods ) ) {
67
+		if (array_key_exists($type, $methods)) {
68 68
 			$method = $methods[$type];
69
-			$serializedValue = $this->$method( $value );
69
+			$serializedValue = $this->$method($value);
70 70
 		} else {
71 71
 			throw new InvalidArgumentException(
72
-				'Unknown ViolationMessage argument type ' . $type . '!'
72
+				'Unknown ViolationMessage argument type '.$type.'!'
73 73
 			);
74 74
 		}
75 75
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @param string $string any value that shall simply be serialized to itself
87 87
 	 * @return string that same value, unchanged
88 88
 	 */
89
-	private function serializeStringByIdentity( $string ) {
90
-		Assert::parameterType( 'string', $string, '$string' );
89
+	private function serializeStringByIdentity($string) {
90
+		Assert::parameterType('string', $string, '$string');
91 91
 		return $string;
92 92
 	}
93 93
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @param EntityId $entityId
96 96
 	 * @return string entity ID serialization
97 97
 	 */
98
-	private function serializeEntityId( EntityId $entityId ) {
98
+	private function serializeEntityId(EntityId $entityId) {
99 99
 		return $entityId->getSerialization();
100 100
 	}
101 101
 
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 * @param EntityId[] $entityIdList
104 104
 	 * @return string[] entity ID serializations
105 105
 	 */
106
-	private function serializeEntityIdList( array $entityIdList ) {
107
-		return array_map( [ $this, 'serializeEntityId' ], $entityIdList );
106
+	private function serializeEntityIdList(array $entityIdList) {
107
+		return array_map([$this, 'serializeEntityId'], $entityIdList);
108 108
 	}
109 109
 
110 110
 	/**
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	 * @return string entity ID serialization, '::somevalue', or '::novalue'
113 113
 	 * (according to EntityId::PATTERN, entity ID serializations can never begin with two colons)
114 114
 	 */
115
-	private function serializeItemIdSnakValue( ItemIdSnakValue $value ) {
116
-		switch ( true ) {
115
+	private function serializeItemIdSnakValue(ItemIdSnakValue $value) {
116
+		switch (true) {
117 117
 			case $value->isValue():
118
-				return $this->serializeEntityId( $value->getItemId() );
118
+				return $this->serializeEntityId($value->getItemId());
119 119
 			case $value->isSomeValue():
120 120
 				return '::somevalue';
121 121
 			case $value->isNoValue():
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 	 * @param ItemIdSnakValue[] $valueList
134 134
 	 * @return string[] array of entity ID serializations, '::somevalue's or '::novalue's
135 135
 	 */
136
-	private function serializeItemIdSnakValueList( array $valueList ) {
137
-		return array_map( [ $this, 'serializeItemIdSnakValue' ], $valueList );
136
+	private function serializeItemIdSnakValueList(array $valueList) {
137
+		return array_map([$this, 'serializeItemIdSnakValue'], $valueList);
138 138
 	}
139 139
 
140 140
 	/**
141 141
 	 * @param DataValue $dataValue
142 142
 	 * @return array the data value in array form
143 143
 	 */
144
-	private function serializeDataValue( DataValue $dataValue ) {
144
+	private function serializeDataValue(DataValue $dataValue) {
145 145
 		return $dataValue->toArray();
146 146
 	}
147 147
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @param string $scope one of the Context::TYPE_* constants
150 150
 	 * @return string the abbreviated scope
151 151
 	 */
152
-	private function serializeConstraintScope( $scope ) {
153
-		switch ( $scope ) {
152
+	private function serializeConstraintScope($scope) {
153
+		switch ($scope) {
154 154
 			case Context::TYPE_STATEMENT:
155 155
 				return 's';
156 156
 			case Context::TYPE_QUALIFIER:
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			default:
161 161
 				// @codeCoverageIgnoreStart
162 162
 				throw new LogicException(
163
-					'Unknown constraint scope ' . $scope
163
+					'Unknown constraint scope '.$scope
164 164
 				);
165 165
 				// @codeCoverageIgnoreEnd
166 166
 		}
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @param string[] $scopeList Context::TYPE_* constants
171 171
 	 * @return string[] abbreviated scopes
172 172
 	 */
173
-	private function serializeConstraintScopeList( array $scopeList ) {
174
-		return array_map( [ $this, 'serializeConstraintScope' ], $scopeList );
173
+	private function serializeConstraintScopeList(array $scopeList) {
174
+		return array_map([$this, 'serializeConstraintScope'], $scopeList);
175 175
 	}
176 176
 
177 177
 }
Please login to merge, or discard this patch.