Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
ErrorEvent
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 exception
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toParams
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <nick@popphp.org>
8 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Event;
16
17use Pop\Application;
18
19/**
20 * Application error event class
21 *
22 * @category   Pop
23 * @package    Pop\Event
24 * @author     Nick Sagona, III <nick@popphp.org>
25 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
26 * @license    https://www.popphp.org/license     New BSD License
27 * @version    5.0.0
28 */
29class ErrorEvent extends AbstractApplicationEvent
30{
31
32    /**
33     * Exception object
34     * @var \Throwable
35     */
36    protected \Throwable $exception;
37
38    /**
39     * Constructor
40     *
41     * Instantiate the application error event object.
42     *
43     * @param  Application $application
44     * @param  \Throwable  $exception
45     */
46    public function __construct(Application $application, \Throwable $exception)
47    {
48        parent::__construct($application);
49        $this->exception = $exception;
50    }
51
52    /**
53     * Get the event name
54     *
55     * @return string
56     */
57    public function getName(): string
58    {
59        return 'app.error';
60    }
61
62    /**
63     * Get the exception object
64     *
65     * @return \Throwable
66     */
67    public function exception(): \Throwable
68    {
69        return $this->exception;
70    }
71
72    /**
73     * Get the params array
74     *
75     * @return array
76     */
77    public function toParams(): array
78    {
79        return ['exception' => $this->exception, 'application' => $this->application];
80    }
81
82}