1 | <?php |
||
29 | class RequestBuilder |
||
30 | { |
||
31 | /** |
||
32 | * @var \Psr\Cache\CacheItemPoolInterface |
||
33 | */ |
||
34 | private $cache; |
||
35 | /** |
||
36 | * @var ParserGenerator |
||
37 | */ |
||
38 | private $parserGenerator; |
||
39 | |||
40 | /** |
||
41 | * Class constructor. |
||
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 | * |
||
47 | */ |
||
48 | 89 | public function __construct( |
|
49 | PsrCache $cache, |
||
50 | ParserGenerator $parserGenerator |
||
51 | ) { |
||
52 | 89 | $this->cache = $cache; |
|
53 | 89 | $this->parserGenerator = $parserGenerator; |
|
54 | 89 | } |
|
55 | |||
56 | /** |
||
57 | * Main method of this class. Used to convert a request to an object of a given class by |
||
58 | * using a requestParser. |
||
59 | * |
||
60 | * @param array|\stdClass $request The request to convert to an object. |
||
61 | * @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 | */ |
||
64 | 89 | public function parseRequest( |
|
65 | $request, |
||
66 | $className, |
||
67 | RequestParser $requestParser |
||
68 | ) { |
||
69 | 89 | return $this->generateRequestParserObject($className, $requestParser) |
|
70 | 89 | ->parse($this->sanitizeRequestOrThrowExceptionIfInvalid($request)); |
|
71 | } |
||
72 | |||
73 | 89 | private function generateRequestParserObject($className, $parser) |
|
86 | |||
87 | 89 | private function sanitizeRequestOrThrowExceptionIfInvalid($request) |
|
88 | { |
||
97 | } |
||
98 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.