Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 3.4746 |
Changes | 0 |
1 | <?php |
||
25 | 7 | public function assetExists($path) |
|
26 | { |
||
27 | 7 | $publicRoot = realpath($this->kernel->getRootDir() . '/../public/') . DIRECTORY_SEPARATOR; |
|
28 | 7 | $toCheck = realpath($publicRoot . $path); |
|
|
|||
29 | |||
30 | // check if the file exists |
||
31 | 7 | if (!is_file($toCheck)) { |
|
32 | 7 | return false; |
|
33 | } |
||
34 | |||
35 | // check if file is well contained in web/ directory (prevents ../ in paths) |
||
36 | if (strncmp($publicRoot, $toCheck, strlen($publicRoot)) !== 0) { |
||
37 | return false; |
||
38 | } |
||
39 | |||
40 | return true; |
||
41 | } |
||
48 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.