@@ -68,8 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | private function getPropertyAccessor() |
| 70 | 70 | { |
| 71 | - $this->propertyAccessor = $this->propertyAccessor ?: |
|
| 72 | - PropertyAccess::createPropertyAccessor() |
|
| 71 | + $this->propertyAccessor = $this->propertyAccessor ?: PropertyAccess::createPropertyAccessor() |
|
| 73 | 72 | ; |
| 74 | 73 | |
| 75 | 74 | return $this->propertyAccessor; |
@@ -127,8 +126,7 @@ discard block |
||
| 127 | 126 | $propertyAccessor = $this->getPropertyAccessor(); |
| 128 | 127 | if (!$this->_has($field)) { |
| 129 | 128 | return $propertyAccessor->isReadable($object, $field) ? |
| 130 | - $propertyAccessor->getValue($object, $field) : |
|
| 131 | - null |
|
| 129 | + $propertyAccessor->getValue($object, $field) : null |
|
| 132 | 130 | ; |
| 133 | 131 | } |
| 134 | 132 | |
@@ -157,7 +155,7 @@ discard block |
||
| 157 | 155 | $data = $this->getAttributes()->toArray(); |
| 158 | 156 | |
| 159 | 157 | $scopes = $this->getScopes(); |
| 160 | - if(empty($scopes[$scope])) { |
|
| 158 | + if (empty($scopes[$scope])) { |
|
| 161 | 159 | return $data; |
| 162 | 160 | } |
| 163 | 161 | |
@@ -167,11 +165,9 @@ discard block |
||
| 167 | 165 | $normalizedData[$field] = $propertyAccessor->isReadable( |
| 168 | 166 | $data, |
| 169 | 167 | $propertyPath = strpos($field, '[') === 0 ? |
| 170 | - $field : |
|
| 171 | - sprintf('[%s]', $field) |
|
| 168 | + $field : sprintf('[%s]', $field) |
|
| 172 | 169 | ) ? |
| 173 | - $propertyAccessor->getValue($data, $propertyPath) : |
|
| 174 | - null |
|
| 170 | + $propertyAccessor->getValue($data, $propertyPath) : null |
|
| 175 | 171 | ; |
| 176 | 172 | } |
| 177 | 173 | |
@@ -36,8 +36,7 @@ |
||
| 36 | 36 | return $this->actionFactory |
| 37 | 37 | ->createAction($name) |
| 38 | 38 | ->denormalize(isset($arguments[0]) && is_array($arguments[0]) ? |
| 39 | - $arguments[0] : |
|
| 40 | - array() |
|
| 39 | + $arguments[0] : array() |
|
| 41 | 40 | ) |
| 42 | 41 | ->init($relatedEntity, ...$arguments) |
| 43 | 42 | ; |
@@ -52,8 +52,7 @@ |
||
| 52 | 52 | |
| 53 | 53 | // default locale matched |
| 54 | 54 | return $this->defaultLocale && isset($translationData[$this->defaultLocale]) ? |
| 55 | - $translationData[$this->defaultLocale] : |
|
| 56 | - $default |
|
| 55 | + $translationData[$this->defaultLocale] : $default |
|
| 57 | 56 | ; |
| 58 | 57 | } |
| 59 | 58 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public function normalize($scope = 'default') |
| 39 | 39 | { |
| 40 | 40 | return $this |
| 41 | - ->map(function (NormalizableInterface $entity) use ($scope) { |
|
| 41 | + ->map(function(NormalizableInterface $entity) use ($scope) { |
|
| 42 | 42 | return $entity->normalize($scope); |
| 43 | 43 | }) |
| 44 | 44 | ->toArray() |
@@ -92,13 +92,12 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $propertyAccessor = PropertyAccess::createPropertyAccessor(); |
| 94 | 94 | |
| 95 | - return $this->filter(function (CollectionableInterface $entity) use ($filters, $propertyAccessor) { |
|
| 95 | + return $this->filter(function(CollectionableInterface $entity) use ($filters, $propertyAccessor) { |
|
| 96 | 96 | $res = true; |
| 97 | 97 | foreach ($filters as $key => $value) { |
| 98 | 98 | $current = $propertyAccessor->getValue($entity, $key); |
| 99 | 99 | $res = $res && (is_array($value) ? |
| 100 | - in_array($current, $value) : |
|
| 101 | - $current == $value |
|
| 100 | + in_array($current, $value) : $current == $value |
|
| 102 | 101 | ); |
| 103 | 102 | } |
| 104 | 103 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $statusCode = $exception instanceof HttpException ? $exception->getStatusCode() : 500; |
| 63 | 63 | $errors = array(); |
| 64 | 64 | |
| 65 | - switch(true) { |
|
| 65 | + switch (true) { |
|
| 66 | 66 | |
| 67 | 67 | // validation exception |
| 68 | 68 | case $exception instanceof ValidationException : |
@@ -99,8 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $violation = $violation instanceof FormError ? |
| 102 | - $violation->getCause() : |
|
| 103 | - $violation |
|
| 102 | + $violation->getCause() : $violation |
|
| 104 | 103 | ; |
| 105 | 104 | |
| 106 | 105 | $errors[(string) $violation->getPropertyPath()] = $violation->getMessage(); |
@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | 'Validation failed on %s%s', |
| 57 | 57 | $this->entity ? get_class($this->entity) : '', |
| 58 | 58 | $this->entity instanceof CollectionableInterface ? |
| 59 | - sprintf('#%s', $this->entity->getId()) : |
|
| 60 | - '' |
|
| 59 | + sprintf('#%s', $this->entity->getId()) : '' |
|
| 61 | 60 | , |
| 62 | 61 | empty($this->groups) ? '' : sprintf(' for ["%s"] groups', |
| 63 | 62 | implode('", "', $this->groups) |
@@ -96,8 +95,7 @@ discard block |
||
| 96 | 95 | public function getReport() |
| 97 | 96 | { |
| 98 | 97 | return $this->report ? |
| 99 | - $this->report : |
|
| 100 | - new EntityCollection() |
|
| 98 | + $this->report : new EntityCollection() |
|
| 101 | 99 | ; |
| 102 | 100 | } |
| 103 | 101 | |
@@ -106,14 +104,14 @@ discard block |
||
| 106 | 104 | * |
| 107 | 105 | * @return array |
| 108 | 106 | */ |
| 109 | - public function formatReport(){ |
|
| 107 | + public function formatReport() { |
|
| 110 | 108 | $messages = array(); |
| 111 | 109 | $report = $this->getReport(); |
| 112 | 110 | |
| 113 | - switch(true){ |
|
| 111 | + switch (true) { |
|
| 114 | 112 | |
| 115 | 113 | case $report instanceof ConstraintViolationListInterface: |
| 116 | - foreach ($report as $constraintViolation){ |
|
| 114 | + foreach ($report as $constraintViolation) { |
|
| 117 | 115 | $messages[] = $constraintViolation->getMessage(); |
| 118 | 116 | } |
| 119 | 117 | break; |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | public function serialize($data, $scope) |
| 19 | 19 | { |
| 20 | 20 | return $data instanceof SerializableInterface ? |
| 21 | - $data->serialize($scope) : |
|
| 22 | - (array) $data |
|
| 21 | + $data->serialize($scope) : (array) $data |
|
| 23 | 22 | ; |
| 24 | 23 | } |
| 25 | 24 | |
@@ -35,8 +34,7 @@ discard block |
||
| 35 | 34 | $object = new $output(); |
| 36 | 35 | |
| 37 | 36 | return $object instanceof SerializableInterface ? |
| 38 | - $object->deserialize($data) : |
|
| 39 | - $object |
|
| 37 | + $object->deserialize($data) : $object |
|
| 40 | 38 | ; |
| 41 | 39 | } |
| 42 | 40 | } |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | public function serialize($data, $scope) |
| 18 | 18 | { |
| 19 | 19 | return json_encode($data instanceof NormalizableInterface ? |
| 20 | - $this->normalizer->normalize($data, $scope) : |
|
| 21 | - $data |
|
| 20 | + $this->normalizer->normalize($data, $scope) : $data |
|
| 22 | 21 | ); |
| 23 | 22 | } |
| 24 | 23 | |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | public static function createNormalizer($key = 'default') |
| 63 | 63 | { |
| 64 | 64 | return isset(self::$instancePool[$key]) ? |
| 65 | - self::$instancePool[$key] : |
|
| 66 | - self::$instancePool[$key] = new static( |
|
| 65 | + self::$instancePool[$key] : self::$instancePool[$key] = new static( |
|
| 67 | 66 | PropertyAccess::createPropertyAccessor() |
| 68 | 67 | ); |
| 69 | 68 | } |
@@ -86,7 +85,7 @@ discard block |
||
| 86 | 85 | */ |
| 87 | 86 | private function createExtractorDelegate() |
| 88 | 87 | { |
| 89 | - return $this->extractorDelegate ?: $this->extractorDelegate = function () { |
|
| 88 | + return $this->extractorDelegate ?: $this->extractorDelegate = function() { |
|
| 90 | 89 | return get_object_vars($this); |
| 91 | 90 | }; |
| 92 | 91 | } |
@@ -98,7 +97,7 @@ discard block |
||
| 98 | 97 | */ |
| 99 | 98 | private function createReadingDelegate() |
| 100 | 99 | { |
| 101 | - return $this->readDelegate ?: $this->readDelegate = function ($property, PropertyAccessor $propertyAccessor) { |
|
| 100 | + return $this->readDelegate ?: $this->readDelegate = function($property, PropertyAccessor $propertyAccessor) { |
|
| 102 | 101 | switch (true) { |
| 103 | 102 | |
| 104 | 103 | // Public property / accessor case |
@@ -259,7 +258,7 @@ discard block |
||
| 259 | 258 | */ |
| 260 | 259 | private function createWrittingDelegate() |
| 261 | 260 | { |
| 262 | - return $this->writeDelegate ?: $this->writeDelegate = function ($property, $value, PropertyAccessor $propertyAccessor) { |
|
| 261 | + return $this->writeDelegate ?: $this->writeDelegate = function($property, $value, PropertyAccessor $propertyAccessor) { |
|
| 263 | 262 | switch (true) { |
| 264 | 263 | |
| 265 | 264 | // Public property / accessor case |
@@ -293,15 +292,12 @@ discard block |
||
| 293 | 292 | $class = is_string($normalizable) ? |
| 294 | 293 | $normalizable : ( |
| 295 | 294 | $normalizable instanceof \ReflectionClass ? |
| 296 | - $normalizable->name : |
|
| 297 | - get_class($normalizable) |
|
| 295 | + $normalizable->name : get_class($normalizable) |
|
| 298 | 296 | ) |
| 299 | 297 | ; |
| 300 | 298 | $reflection = isset(self::$reflectionPool[$class]) ? |
| 301 | - self::$reflectionPool[$class] : |
|
| 302 | - self::$reflectionPool[$class] = $normalizable instanceof \ReflectionClass ? |
|
| 303 | - $normalizable : |
|
| 304 | - new \ReflectionClass($class) |
|
| 299 | + self::$reflectionPool[$class] : self::$reflectionPool[$class] = $normalizable instanceof \ReflectionClass ? |
|
| 300 | + $normalizable : new \ReflectionClass($class) |
|
| 305 | 301 | ; |
| 306 | 302 | |
| 307 | 303 | $object = $normalizable; |
@@ -328,8 +324,7 @@ discard block |
||
| 328 | 324 | $argKey = $this->inflector->snakelize($parameter->getName()); |
| 329 | 325 | if (isset($data[$argKey])) { |
| 330 | 326 | $arguments[] = $parameter->getClass() ? |
| 331 | - $this->normalize($data[$argKey], $parameter->getClass()) : |
|
| 332 | - $data[$argKey] |
|
| 327 | + $this->normalize($data[$argKey], $parameter->getClass()) : $data[$argKey] |
|
| 333 | 328 | ; |
| 334 | 329 | unset($data[$argKey]); |
| 335 | 330 | |
@@ -337,16 +332,14 @@ discard block |
||
| 337 | 332 | } |
| 338 | 333 | |
| 339 | 334 | $arguments[] = $parameter->isOptional() ? |
| 340 | - $parameter->getDefaultValue() : |
|
| 341 | - null |
|
| 335 | + $parameter->getDefaultValue() : null |
|
| 342 | 336 | ; |
| 343 | 337 | } |
| 344 | 338 | } |
| 345 | 339 | } |
| 346 | 340 | |
| 347 | 341 | $object = empty($arguments) ? |
| 348 | - $reflection->newInstance() : |
|
| 349 | - $reflection->newInstanceArgs($arguments); |
|
| 342 | + $reflection->newInstance() : $reflection->newInstanceArgs($arguments); |
|
| 350 | 343 | } |
| 351 | 344 | |
| 352 | 345 | // BAD ! |