@@ -18,13 +18,6 @@ |
||
18 | 18 | namespace Mcustiel\SimpleRequest; |
19 | 19 | |
20 | 20 | use Doctrine\Common\Annotations\AnnotationReader; |
21 | -use Mcustiel\SimpleRequest\Util\ValidatorBuilder; |
|
22 | -use Mcustiel\SimpleRequest\Annotation\RequestAnnotation; |
|
23 | -use Mcustiel\SimpleRequest\Annotation\ValidatorAnnotation; |
|
24 | -use Mcustiel\SimpleRequest\Annotation\FilterAnnotation; |
|
25 | -use Mcustiel\SimpleRequest\Util\FilterBuilder; |
|
26 | -use Mcustiel\SimpleRequest\Annotation\ParseAs; |
|
27 | -use Mcustiel\SimpleRequest\Annotation\AnnotationWithAssociatedClass; |
|
28 | 21 | use Mcustiel\SimpleRequest\Strategies\AnnotationParserFactory; |
29 | 22 | use Mcustiel\SimpleRequest\Strategies\PropertyParserBuilder; |
30 | 23 | use Mcustiel\SimpleRequest\Strategies\Properties\PropertyParser; |
@@ -41,9 +41,6 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Class constructor. |
43 | 43 | * |
44 | - * @param \stdClass $cacheConfig |
|
45 | - * Config parameters for cache. By default cache is activated and saves files |
|
46 | - * under system's temp dir. This parameter is used to set alternative options. |
|
47 | 44 | * |
48 | 45 | */ |
49 | 46 | public function __construct( |
@@ -60,7 +57,6 @@ discard block |
||
60 | 57 | * |
61 | 58 | * @param array|\stdClass $request The request to convert to an object. |
62 | 59 | * @param string $className The class of the object to which the request must be converted. |
63 | - * @param string $behaviour The behaviour of the parser. |
|
64 | 60 | */ |
65 | 61 | public function parseRequest( |
66 | 62 | $request, |
@@ -71,6 +67,10 @@ discard block |
||
71 | 67 | ->parse($this->sanitizeRequestOrThrowExceptionIfInvalid($request)); |
72 | 68 | } |
73 | 69 | |
70 | + /** |
|
71 | + * @param string $className |
|
72 | + * @param RequestParser $parser |
|
73 | + */ |
|
74 | 74 | private function generateRequestParserObject($className, $parser) |
75 | 75 | { |
76 | 76 | $cacheKey = str_replace('\\', '', $className . get_class($parser)); |
@@ -19,7 +19,6 @@ |
||
19 | 19 | |
20 | 20 | use Mcustiel\SimpleRequest\Exception\InvalidRequestException; |
21 | 21 | use Psr\Cache\CacheItemPoolInterface as PsrCache; |
22 | -use Symfony\Component\Cache\CacheItem; |
|
23 | 22 | |
24 | 23 | /** |
25 | 24 | * Builds a request by parsing all the resulting object's annotations and running |
@@ -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) { |
@@ -48,7 +48,6 @@ |
||
48 | 48 | * Filters and validates a value. And return the filtered value. |
49 | 49 | * It throws an exception if the value is not valid. |
50 | 50 | * |
51 | - * @param mixed $value |
|
52 | 51 | * @return mixed |
53 | 52 | * |
54 | 53 | * @throws \Mcustiel\SimpleRequest\Exception\InvalidValueException |
@@ -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 | } |
@@ -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 | } |