@@ -41,14 +41,14 @@ |
||
| 41 | 41 | 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, |
| 42 | 42 | 'type' => $type, |
| 43 | 43 | 'format' => $format, |
| 44 | - 'method' => 'serialize' . $shortName, |
|
| 44 | + 'method' => 'serialize'.$shortName, |
|
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | 47 | $methods[] = array( |
| 48 | 48 | 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, |
| 49 | 49 | 'type' => $type, |
| 50 | 50 | 'format' => $format, |
| 51 | - 'method' => 'deserialize' . $shortName, |
|
| 51 | + 'method' => 'deserialize'.$shortName, |
|
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | return $this->serializationVisitors->get($format) |
| 109 | - ->map(function (VisitorInterface $visitor) use ($context, $data, $format) { |
|
| 109 | + ->map(function(VisitorInterface $visitor) use ($context, $data, $format) { |
|
| 110 | 110 | $type = $context->getInitialType() !== null ? $this->typeParser->parse($context->getInitialType()) : null; |
| 111 | 111 | |
| 112 | 112 | $this->visit($visitor, $context, $visitor->prepare($data), $format, $type); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $this->deserializationVisitors->get($format) |
| 126 | - ->map(function (VisitorInterface $visitor) use ($context, $data, $format, $type) { |
|
| 126 | + ->map(function(VisitorInterface $visitor) use ($context, $data, $format, $type) { |
|
| 127 | 127 | $preparedData = $visitor->prepare($data); |
| 128 | 128 | $navigatorResult = $this->visit($visitor, $context, $preparedData, $format, $this->typeParser->parse($type)); |
| 129 | 129 | |
@@ -142,13 +142,13 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | return $this->serializationVisitors->get('json') |
| 145 | - ->map(function (JsonSerializationVisitor $visitor) use ($context, $data) { |
|
| 145 | + ->map(function(JsonSerializationVisitor $visitor) use ($context, $data) { |
|
| 146 | 146 | $type = $context->getInitialType() !== null ? $this->typeParser->parse($context->getInitialType()) : null; |
| 147 | 147 | |
| 148 | 148 | $this->visit($visitor, $context, $data, 'json', $type); |
| 149 | 149 | $result = $this->convertArrayObjects($visitor->getRoot()); |
| 150 | 150 | |
| 151 | - if (!is_array($result)) { |
|
| 151 | + if ( ! is_array($result)) { |
|
| 152 | 152 | throw new RuntimeException(sprintf( |
| 153 | 153 | 'The input data of type "%s" did not convert to an array, but got a result of type "%s".', |
| 154 | 154 | is_object($data) ? get_class($data) : gettype($data), |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $this->deserializationVisitors->get('json') |
| 174 | - ->map(function (JsonDeserializationVisitor $visitor) use ($data, $type, $context) { |
|
| 174 | + ->map(function(JsonDeserializationVisitor $visitor) use ($data, $type, $context) { |
|
| 175 | 175 | $navigatorResult = $this->visit($visitor, $context, $data, 'json', $this->typeParser->parse($type)); |
| 176 | 176 | |
| 177 | 177 | return $this->handleDeserializeResult($visitor->getResult(), $navigatorResult); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | private function convertArrayObjects($data) |
| 207 | 207 | { |
| 208 | 208 | if ($data instanceof \ArrayObject || $data instanceof \stdClass) { |
| 209 | - $data = (array)$data; |
|
| 209 | + $data = (array) $data; |
|
| 210 | 210 | } |
| 211 | 211 | if (is_array($data)) { |
| 212 | 212 | foreach ($data as $k => $v) { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function visitString($data, array $type, Context $context) |
| 60 | 60 | { |
| 61 | - $data = (string)$data; |
|
| 61 | + $data = (string) $data; |
|
| 62 | 62 | |
| 63 | 63 | if (null === $this->result) { |
| 64 | 64 | $this->result = $data; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | public function visitBoolean($data, array $type, Context $context) |
| 71 | 71 | { |
| 72 | - $data = (Boolean)$data; |
|
| 72 | + $data = (Boolean) $data; |
|
| 73 | 73 | |
| 74 | 74 | if (null === $this->result) { |
| 75 | 75 | $this->result = $data; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function visitInteger($data, array $type, Context $context) |
| 82 | 82 | { |
| 83 | - $data = (integer)$data; |
|
| 83 | + $data = (integer) $data; |
|
| 84 | 84 | |
| 85 | 85 | if (null === $this->result) { |
| 86 | 86 | $this->result = $data; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function visitDouble($data, array $type, Context $context) |
| 93 | 93 | { |
| 94 | - $data = (double)$data; |
|
| 94 | + $data = (double) $data; |
|
| 95 | 95 | |
| 96 | 96 | if (null === $this->result) { |
| 97 | 97 | $this->result = $data; |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | public function visitArray($data, array $type, Context $context) |
| 104 | 104 | { |
| 105 | - if (!is_array($data)) { |
|
| 105 | + if ( ! is_array($data)) { |
|
| 106 | 106 | throw new RuntimeException(sprintf('Expected array, but got %s: %s', gettype($data), json_encode($data))); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // If no further parameters were given, keys/values are just passed as is. |
| 110 | - if (!$type['params']) { |
|
| 110 | + if ( ! $type['params']) { |
|
| 111 | 111 | if (null === $this->result) { |
| 112 | 112 | $this->result = $data; |
| 113 | 113 | } |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if (!is_array($data)) { |
|
| 169 | + if ( ! is_array($data)) { |
|
| 170 | 170 | throw new RuntimeException(sprintf('Invalid data "%s"(%s), expected "%s".', $data, $metadata->type['name'], $metadata->reflection->class)); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - if (!array_key_exists($name, $data)) { |
|
| 173 | + if ( ! array_key_exists($name, $data)) { |
|
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if (!$metadata->type) { |
|
| 177 | + if ( ! $metadata->type) { |
|
| 178 | 178 | throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name)); |
| 179 | 179 | } |
| 180 | 180 | |