| Total Complexity | 10 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class ApiRequestInspector |
||
| 13 | { |
||
| 14 | /** @var ApiRequestAbstract */ |
||
| 15 | private $request = null; |
||
| 16 | |||
| 17 | public function __construct(array $parameters) |
||
| 18 | { |
||
| 19 | $this->setRequestReceivedAtApiEndpoint($parameters); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function inspect() |
||
| 23 | { |
||
| 24 | $this->sanitizeIncludes(); |
||
| 25 | } |
||
| 26 | |||
| 27 | private function setRequestReceivedAtApiEndpoint(array $parameters) |
||
| 28 | { |
||
| 29 | foreach ($parameters as $parameter) { |
||
| 30 | if ($parameter instanceof Request) { |
||
| 31 | $this->request = $parameter; |
||
|
|
|||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | private function sanitizeIncludes() |
||
| 41 | } |
||
| 42 | }); |
||
| 43 | } |
||
| 44 | |||
| 45 | private function isIncludeAllowed($field): bool |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.