| 1 | <?php |
||
| 11 | class ExceptionAsString |
||
| 12 | { |
||
| 13 | 3 | public function summery(\Exception $e, $log) |
|
| 17 | |||
| 18 | /** |
||
| 19 | * @param \Exception $e |
||
| 20 | * @param Request $request |
||
| 21 | * |
||
| 22 | * @return string |
||
| 23 | */ |
||
| 24 | 3 | public function detail(\Exception $e, Request $request) |
|
|
1 ignored issue
–
show
|
|||
| 25 | { |
||
| 26 | 3 | $eSummery = sprintf( |
|
| 27 | 3 | "[%s]\n%s\nin file %s on line %s\n\n%s", |
|
| 28 | get_class($e), |
||
| 29 | 3 | $e->getMessage(), |
|
| 30 | 3 | $e->getFile(), |
|
| 31 | 3 | $e->getLine(), |
|
| 32 | 3 | $e->getTraceAsString() |
|
| 33 | ); |
||
| 34 | |||
| 35 | 3 | return sprintf("%s\n%s\n\n%s\n%s", date(DATE_RFC2822), $request, $eSummery, $this->getPhpVariables($_SERVER)); |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param array $server |
||
| 40 | * |
||
| 41 | * @return string |
||
| 42 | */ |
||
| 43 | 3 | private function getPhpVariables(array $server) |
|
| 51 | } |
||
| 52 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: