@@ -18,29 +18,29 @@ |
||
18 | 18 | */ |
19 | 19 | public function __construct() |
20 | 20 | { |
21 | - $this->registerExceptionHandler(); |
|
21 | + $this->registerExceptionHandler(); |
|
22 | 22 | |
23 | - $this->createContainer(); |
|
23 | + $this->createContainer(); |
|
24 | 24 | |
25 | - $this->loadEnvironment(); |
|
25 | + $this->loadEnvironment(); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | private function registerExceptionHandler() |
29 | - { |
|
30 | - $handler = new Handler(new DefaultFormatter()); |
|
29 | + { |
|
30 | + $handler = new Handler(new DefaultFormatter()); |
|
31 | 31 | |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | 34 | private function createContainer() |
35 | - { |
|
36 | - $container = new Container; |
|
37 | - $container->delegate(new ReflectionContainer); |
|
38 | - $this->setContainer($container); |
|
39 | - } |
|
40 | - |
|
41 | - private function loadEnvironment() |
|
42 | - { |
|
43 | - $environment = new Dotenv(getcwd() . '/../'); |
|
44 | - $environment->load(); |
|
45 | - } |
|
35 | + { |
|
36 | + $container = new Container; |
|
37 | + $container->delegate(new ReflectionContainer); |
|
38 | + $this->setContainer($container); |
|
39 | + } |
|
40 | + |
|
41 | + private function loadEnvironment() |
|
42 | + { |
|
43 | + $environment = new Dotenv(getcwd() . '/../'); |
|
44 | + $environment->load(); |
|
45 | + } |
|
46 | 46 | } |
@@ -7,12 +7,12 @@ |
||
7 | 7 | class DefaultFormatter implements FormatterInterface |
8 | 8 | { |
9 | 9 | |
10 | - public function format(\Throwable $e): array |
|
11 | - { |
|
12 | - return [ |
|
13 | - 'message' => $e->getMessage(), |
|
14 | - 'file' => $e->getFile(), |
|
15 | - 'line' => $e->getLine(), |
|
16 | - ]; |
|
17 | - } |
|
10 | + public function format(\Throwable $e): array |
|
11 | + { |
|
12 | + return [ |
|
13 | + 'message' => $e->getMessage(), |
|
14 | + 'file' => $e->getFile(), |
|
15 | + 'line' => $e->getLine(), |
|
16 | + ]; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -7,65 +7,65 @@ |
||
7 | 7 | |
8 | 8 | class Handler |
9 | 9 | { |
10 | - const ERROR_HANDLER = 'handleError'; |
|
11 | - const EXCEPTION_HANDLER = 'handleException'; |
|
10 | + const ERROR_HANDLER = 'handleError'; |
|
11 | + const EXCEPTION_HANDLER = 'handleException'; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var FormatterInterface |
|
15 | - */ |
|
16 | - private $formatter; |
|
13 | + /** |
|
14 | + * @var FormatterInterface |
|
15 | + */ |
|
16 | + private $formatter; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Handler constructor. |
|
20 | - * |
|
21 | - * @param FormatterInterface $formatter |
|
22 | - */ |
|
23 | - public function __construct(FormatterInterface $formatter) |
|
24 | - { |
|
25 | - $this->formatter = $formatter; |
|
26 | - } |
|
18 | + /** |
|
19 | + * Handler constructor. |
|
20 | + * |
|
21 | + * @param FormatterInterface $formatter |
|
22 | + */ |
|
23 | + public function __construct(FormatterInterface $formatter) |
|
24 | + { |
|
25 | + $this->formatter = $formatter; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Register the PHP error handler. |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - protected function registerErrorHandler() |
|
34 | - { |
|
35 | - set_error_handler(array($this, self::ERROR_HANDLER)); |
|
36 | - } |
|
28 | + /** |
|
29 | + * Register the PHP error handler. |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + protected function registerErrorHandler() |
|
34 | + { |
|
35 | + set_error_handler(array($this, self::ERROR_HANDLER)); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Register the PHP exception handler. |
|
40 | - * |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - protected function registerExceptionHandler() |
|
44 | - { |
|
45 | - set_exception_handler(array($this, self::EXCEPTION_HANDLER)); |
|
46 | - } |
|
38 | + /** |
|
39 | + * Register the PHP exception handler. |
|
40 | + * |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + protected function registerExceptionHandler() |
|
44 | + { |
|
45 | + set_exception_handler(array($this, self::EXCEPTION_HANDLER)); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param int $level |
|
50 | - * @param string $message |
|
51 | - * @param string $file |
|
52 | - * @param int $line |
|
53 | - * @param array $context |
|
54 | - * |
|
55 | - * @throws ErrorException |
|
56 | - */ |
|
57 | - public function handleError(int $level, string $message, string $file = '', int $line = 0, array $context = []) |
|
58 | - { |
|
59 | - throw new ErrorException($message, 0, $level, $file, $line); |
|
60 | - } |
|
48 | + /** |
|
49 | + * @param int $level |
|
50 | + * @param string $message |
|
51 | + * @param string $file |
|
52 | + * @param int $line |
|
53 | + * @param array $context |
|
54 | + * |
|
55 | + * @throws ErrorException |
|
56 | + */ |
|
57 | + public function handleError(int $level, string $message, string $file = '', int $line = 0, array $context = []) |
|
58 | + { |
|
59 | + throw new ErrorException($message, 0, $level, $file, $line); |
|
60 | + } |
|
61 | 61 | |
62 | - public function handleException(\Throwable $e) |
|
63 | - { |
|
64 | - ob_start(); |
|
65 | - $response = $this->formatter->format($e); |
|
66 | - ob_end_clean(); |
|
67 | - http_response_code(500); |
|
68 | - print $response; |
|
69 | - return; |
|
70 | - } |
|
62 | + public function handleException(\Throwable $e) |
|
63 | + { |
|
64 | + ob_start(); |
|
65 | + $response = $this->formatter->format($e); |
|
66 | + ob_end_clean(); |
|
67 | + http_response_code(500); |
|
68 | + print $response; |
|
69 | + return; |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | \ No newline at end of file |