| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3.4746 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 11 | public function assetExists($path) |
|
| 20 | { |
||
| 21 | 11 | $publicRoot = realpath($this->projectpath.'/public/').DIRECTORY_SEPARATOR; |
|
| 22 | 11 | $toCheck = $publicRoot.$path; |
|
|
|
|||
| 23 | |||
| 24 | // check if the file exists |
||
| 25 | 11 | if (!is_file($toCheck)) { |
|
| 26 | 11 | return false; |
|
| 27 | } |
||
| 28 | |||
| 29 | // check if file is well contained in web/ directory (prevents ../ in paths) |
||
| 30 | if (0 !== strncmp($publicRoot, $toCheck, strlen($publicRoot))) { |
||
| 31 | return false; |
||
| 32 | } |
||
| 33 | |||
| 34 | return true; |
||
| 35 | } |
||
| 37 |
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.