1 | <?php |
||
10 | class Notifier { |
||
11 | protected $config; |
||
12 | protected $log; |
||
13 | protected $messageCb; |
||
14 | protected $subjectCb; |
||
15 | protected $drivers; |
||
16 | |||
17 | /** |
||
18 | * You can provide a Monolog Logger instance to use in the constructor |
||
19 | * @param Logger|null $log Logger instance to use |
||
20 | */ |
||
21 | 39 | public function __construct(Logger $log = null) { |
|
30 | |||
31 | /** |
||
32 | * Transforms a value into a closure that returns itself when called |
||
33 | * @param callable|string $cb The value that you want to wrap in a closure |
||
34 | * @return callable |
||
35 | */ |
||
36 | 12 | private function wrapValueInClosure($cb) { |
|
43 | |||
44 | /** |
||
45 | * Set a string or a closure to be called that will generate the message body for the notification |
||
46 | * @param callable|string $cb A closure or string that will be set for the message |
||
47 | */ |
||
48 | 6 | public function setMessage($cb) |
|
53 | |||
54 | /** |
||
55 | * Returns the result of the message closure |
||
56 | * @param Exception $e The Exception instance that you want to build the message around |
||
57 | * @return string The message string |
||
58 | */ |
||
59 | 9 | public function getMessage(Exception $e) { |
|
70 | |||
71 | /** |
||
72 | * Set a string or a closure to be called that will generate the subject line for the notification |
||
73 | * @param callable|string $cb A closure or string that will be set for the subject line |
||
74 | */ |
||
75 | 6 | public function setSubject($cb) |
|
80 | |||
81 | /** |
||
82 | * Returns the result of the subject closure |
||
83 | * @param Exception $e The Exception instance that you want to build the subject around |
||
84 | * @return string The subject string |
||
85 | */ |
||
86 | 9 | public function getSubject(Exception $e) { |
|
93 | |||
94 | /** |
||
95 | * Pushes on another Monolog Handler |
||
96 | * @param HandlerInterface $handler The handler instance to add on |
||
97 | * @return Notifier Returns this |
||
98 | */ |
||
99 | 3 | public function pushHandler(HandlerInterface $handler) { |
|
103 | |||
104 | /** |
||
105 | * Triggers the Monolog Logger instance to log an error to all handlers |
||
106 | * @param Exception $e The exception to use |
||
107 | * @param array $context Additional information that you would like to pass to Monolog |
||
108 | * @return Notifier Returns this |
||
109 | */ |
||
110 | 3 | public function send(Exception $e, array $context = []) { |
|
130 | |||
131 | /** |
||
132 | * Builds a context array to pass to Monolog |
||
133 | * @param array $context Additional information that you would like to pass to Monolog |
||
134 | * @return array The modified context array |
||
135 | */ |
||
136 | 3 | protected function buildContext(array $context = []){ |
|
142 | } |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.