DeGraciaMathieu /
Nero
| 1 | <?php |
||
| 2 | |||
| 3 | namespace DeGraciaMathieu\Nero; |
||
| 4 | |||
| 5 | class Breaker { |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Destroy your application |
||
| 9 | * @param string $name |
||
| 10 | * @param mixed $arguments |
||
| 11 | * @return exit |
||
| 12 | */ |
||
| 13 | public static function __callStatic($name, $arguments) |
||
| 14 | { |
||
| 15 | $file = isset($arguments[0]) ? $arguments[0] : self::getFilePath(); |
||
| 16 | |||
| 17 | $line = isset($arguments[1]) ? $arguments[1] : self::getRandomLine($file); |
||
| 18 | |||
| 19 | $parameter = isset($arguments[2]) ? $arguments[2] : null; |
||
| 20 | |||
| 21 | call_user_func_array([new Errors, $name], [$file, $line, $parameter]); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * get the path of the calling page |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | protected static function getFilePath() |
||
| 29 | { |
||
| 30 | $backtrace = debug_backtrace(); |
||
| 31 | |||
| 32 | return $backtrace[1]['file']; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * random number |
||
| 37 | * @param string $path |
||
| 38 | * @return integer |
||
| 39 | */ |
||
| 40 | protected static function getRandomLine($path) |
||
| 41 | { |
||
| 42 | $numberMax = 200; |
||
| 43 | |||
| 44 | if (file_exists($path)) { |
||
| 45 | $numberMax = count(file($path)); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 46 | } |
||
| 47 | |||
| 48 | return rand(1, $numberMax); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |