@@ -45,6 +45,6 @@ |
||
45 | 45 | */ |
46 | 46 | public function validate($value) |
47 | 47 | { |
48 | - return ! $this->validator->validate($value); |
|
48 | + return !$this->validator->validate($value); |
|
49 | 49 | } |
50 | 50 | } |
@@ -37,11 +37,11 @@ |
||
37 | 37 | * @var array |
38 | 38 | */ |
39 | 39 | private $validTypes = [ |
40 | - 'array' => [ 'array' ], |
|
41 | - 'object' => [ 'object' ], |
|
42 | - 'integer' => [ 'integer' ], |
|
43 | - 'number' => [ 'integer', 'double' ], |
|
44 | - 'string' => [ 'string' ], |
|
40 | + 'array' => ['array'], |
|
41 | + 'object' => ['object'], |
|
42 | + 'integer' => ['integer'], |
|
43 | + 'number' => ['integer', 'double'], |
|
44 | + 'string' => ['string'], |
|
45 | 45 | 'boolean' => ['boolean'], |
46 | 46 | 'null' => ['NULL'], |
47 | 47 | ]; |
@@ -44,9 +44,9 @@ |
||
44 | 44 | throw new FilterDoesNotExistException("Filter class {$type} does not exist"); |
45 | 45 | } |
46 | 46 | $filter = new $type; |
47 | - if (! ($filter instanceof FilterInterface)) { |
|
47 | + if (!($filter instanceof FilterInterface)) { |
|
48 | 48 | throw new FilterDoesNotExistException( |
49 | - "Filter class {$type} must implement " . FilterInterface::class |
|
49 | + "Filter class {$type} must implement ".FilterInterface::class |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 |
@@ -43,9 +43,9 @@ |
||
43 | 43 | throw new ValidatorDoesNotExistException("Validator class {$type} does not exist"); |
44 | 44 | } |
45 | 45 | $validator = new $type; |
46 | - if (! ($validator instanceof ValidatorInterface)) { |
|
46 | + if (!($validator instanceof ValidatorInterface)) { |
|
47 | 47 | throw new ValidatorDoesNotExistException( |
48 | - "Validator class {$type} must implement " . ValidatorInterface::class |
|
48 | + "Validator class {$type} must implement ".ValidatorInterface::class |
|
49 | 49 | ); |
50 | 50 | } |
51 | 51 |
@@ -88,7 +88,7 @@ |
||
88 | 88 | foreach ($this->validators as $validator) { |
89 | 89 | if (!$validator->validate($value)) { |
90 | 90 | throw new InvalidValueException( |
91 | - "Field {$this->name}, was set with invalid value: " . var_export($value, true) |
|
91 | + "Field {$this->name}, was set with invalid value: ".var_export($value, true) |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | } |
@@ -47,7 +47,6 @@ |
||
47 | 47 | * Filters and validates a value. And return the filtered value. |
48 | 48 | * It throws an exception if the value is not valid. |
49 | 49 | * |
50 | - * @param mixed $value |
|
51 | 50 | * @return mixed |
52 | 51 | * |
53 | 52 | * @throws \Mcustiel\SimpleRequest\Exception\InvalidValueException |
@@ -29,6 +29,6 @@ |
||
29 | 29 | return new $val; |
30 | 30 | } |
31 | 31 | } |
32 | - throw new \Exception('Unsupported annotation: ' . get_class($annotation)); |
|
32 | + throw new \Exception('Unsupported annotation: '.get_class($annotation)); |
|
33 | 33 | } |
34 | 34 | } |
@@ -78,7 +78,7 @@ |
||
78 | 78 | $value = $propertyParser->parse( |
79 | 79 | $this->getFromRequest($request, $propertyName) |
80 | 80 | ); |
81 | - $method = 'set' . ucfirst($propertyName); |
|
81 | + $method = 'set'.ucfirst($propertyName); |
|
82 | 82 | $object->$method($value); |
83 | 83 | } |
84 | 84 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | try { |
43 | 43 | $this->setProperty($request, $object, $propertyName, $propertyParser); |
44 | 44 | } catch (InvalidValueException $e) { |
45 | - $exception = new InvalidRequestException($propertyName . ': ' . $e->getMessage()); |
|
45 | + $exception = new InvalidRequestException($propertyName.': '.$e->getMessage()); |
|
46 | 46 | $exception->setErrors([$propertyName => $e->getMessage()]); |
47 | 47 | throw $exception; |
48 | 48 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | |
74 | 74 | private function generateRequestParserObject($className, $parser) |
75 | 75 | { |
76 | - $cacheKey = str_replace('\\', '', $className . get_class($parser)); |
|
76 | + $cacheKey = str_replace('\\', '', $className.get_class($parser)); |
|
77 | 77 | $cacheItem = $this->cache->getItem($cacheKey); |
78 | 78 | $return = $cacheItem->get(); |
79 | 79 | if ($return === null) { |
@@ -40,9 +40,6 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * Class constructor. |
42 | 42 | * |
43 | - * @param \stdClass $cacheConfig |
|
44 | - * Config parameters for cache. By default cache is activated and saves files |
|
45 | - * under system's temp dir. This parameter is used to set alternative options. |
|
46 | 43 | * |
47 | 44 | */ |
48 | 45 | public function __construct( |
@@ -59,7 +56,6 @@ discard block |
||
59 | 56 | * |
60 | 57 | * @param array|\stdClass $request The request to convert to an object. |
61 | 58 | * @param string $className The class of the object to which the request must be converted. |
62 | - * @param string $behaviour The behaviour of the parser. |
|
63 | 59 | */ |
64 | 60 | public function parseRequest( |
65 | 61 | $request, |
@@ -70,6 +66,10 @@ discard block |
||
70 | 66 | ->parse($this->sanitizeRequestOrThrowExceptionIfInvalid($request)); |
71 | 67 | } |
72 | 68 | |
69 | + /** |
|
70 | + * @param string $className |
|
71 | + * @param RequestParser $parser |
|
72 | + */ |
|
73 | 73 | private function generateRequestParserObject($className, $parser) |
74 | 74 | { |
75 | 75 | $cacheKey = str_replace('\\', '', $className . get_class($parser)); |