1 | <?php |
||
13 | class LERN |
||
14 | { |
||
15 | /** |
||
16 | * @var Exception |
||
17 | */ |
||
18 | private $exception; |
||
19 | |||
20 | /** |
||
21 | * @var Notifier |
||
22 | */ |
||
23 | private $notifier; |
||
24 | |||
25 | /** |
||
26 | * @var Recorder |
||
27 | */ |
||
28 | private $recorder; |
||
29 | |||
30 | /** |
||
31 | * @param Notifier|null $notifier Notifier instance |
||
32 | * @param Recorder|null $recorder Recorder instance |
||
33 | */ |
||
34 | 27 | public function __construct(Notifier $notifier = null, Recorder $recorder = null) |
|
39 | |||
40 | /** |
||
41 | * Will execute record and notify methods |
||
42 | * @param Exception $e The exception to use |
||
43 | * @return ExceptionModel the recorded Eloquent Model |
||
44 | */ |
||
45 | 3 | public function handle(Exception $e) |
|
51 | |||
52 | /** |
||
53 | * Stores the exception in the database |
||
54 | * @param Exception $e The exception to use |
||
55 | * @return \Tylercd100\LERN\Models\ExceptionModel|false The recorded Exception as an Eloquent Model |
||
56 | */ |
||
57 | 3 | public function record(Exception $e) |
|
62 | |||
63 | /** |
||
64 | * Will send the exception to all monolog handlers |
||
65 | * @param Exception $e The exception to use |
||
66 | * @return void |
||
67 | */ |
||
68 | 3 | public function notify(Exception $e) |
|
73 | |||
74 | /** |
||
75 | * Pushes on another Monolog Handler |
||
76 | * @param HandlerInterface $handler The handler instance to add on |
||
77 | * @return $this |
||
78 | */ |
||
79 | 3 | public function pushHandler(HandlerInterface $handler) { |
|
83 | |||
84 | /** |
||
85 | * Get Notifier |
||
86 | * @return \Tylercd100\LERN\Components\Notifier |
||
87 | */ |
||
88 | 3 | public function getNotifier() |
|
92 | |||
93 | /** |
||
94 | * Set Notifier |
||
95 | * @param \Tylercd100\LERN\Components\Notifier $notifier A Notifier instance to use |
||
96 | * @return \Tylercd100\LERN\LERN |
||
97 | */ |
||
98 | 3 | public function setNotifier(Notifier $notifier) |
|
103 | |||
104 | /** |
||
105 | * Get Recorder |
||
106 | * @return \Tylercd100\LERN\Components\Recorder |
||
107 | */ |
||
108 | 3 | public function getRecorder() |
|
112 | |||
113 | /** |
||
114 | * Set Recorder |
||
115 | * @param \Tylercd100\LERN\Components\Recorder $recorder A Recorder instance to use |
||
116 | * @return \Tylercd100\LERN\LERN |
||
117 | */ |
||
118 | 3 | public function setRecorder(Recorder $recorder) |
|
123 | |||
124 | /** |
||
125 | * Set a string or a closure to be called that will generate the message body for the notification |
||
126 | * @param function|string $cb This closure function will be passed an Exception and must return a string |
||
127 | * @return $this |
||
128 | */ |
||
129 | 3 | public function setMessage($cb) |
|
134 | |||
135 | /** |
||
136 | * Set a string or a closure to be called that will generate the subject line for the notification |
||
137 | * @param function|string $cb This closure function will be passed an Exception and must return a string |
||
138 | * @return $this |
||
139 | */ |
||
140 | 3 | public function setSubject($cb) |
|
145 | |||
146 | /** |
||
147 | * Constructs a Notifier |
||
148 | * |
||
149 | * @param Notifier $notifier |
||
150 | * @return Notifier |
||
151 | */ |
||
152 | 27 | protected function buildNotifier(Notifier $notifier = null) |
|
164 | |||
165 | /** |
||
166 | * Constructs a Recorder |
||
167 | * |
||
168 | * @param Recorder $recorder |
||
169 | * @return Recorder |
||
170 | */ |
||
171 | 27 | protected function buildRecorder(Recorder $recorder = null) |
|
183 | } |