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