1 | <?php |
||
10 | class Notifier { |
||
11 | protected $config; |
||
12 | protected $log; |
||
13 | protected $messageCb; |
||
14 | protected $subjectCb; |
||
15 | |||
16 | /** |
||
17 | * You can provide a Monolog Logger instance to use in the constructor |
||
18 | * @param Logger|null $log Logger instance to use |
||
19 | */ |
||
20 | 36 | public function __construct(Logger $log = null) { |
|
28 | |||
29 | /** |
||
30 | * Transforms a value into a closure that returns itself when called |
||
31 | * @param callable|string $cb The value that you want to wrap in a closure |
||
32 | * @return callable |
||
33 | 6 | */ |
|
34 | private function wrapValueInClosure($cb){ |
||
41 | 6 | ||
42 | /** |
||
43 | * Set a string or a closure to be called that will generate the message body for the notification |
||
44 | * @param callable|string $cb A closure or string that will be set for the message |
||
45 | */ |
||
46 | public function setMessage($cb) |
||
51 | 6 | ||
52 | /** |
||
53 | 3 | * Returns the result of the message closure |
|
54 | 3 | * @param Exception $e The Exception instance that you want to build the message around |
|
55 | 3 | * @return string The message string |
|
56 | 3 | */ |
|
57 | 3 | public function getMessage(Exception $e) { |
|
68 | |||
69 | 3 | /** |
|
70 | 3 | * Set a string or a closure to be called that will generate the subject line for the notification |
|
71 | 3 | * @param callable|string $cb A closure or string that will be set for the subject line |
|
72 | */ |
||
73 | 3 | public function setSubject($cb) |
|
78 | |||
79 | /** |
||
80 | * Returns the result of the subject closure |
||
81 | 6 | * @param Exception $e The Exception instance that you want to build the subject around |
|
82 | 6 | * @return string The subject string |
|
83 | 3 | */ |
|
84 | public function getSubject(Exception $e) { |
||
91 | |||
92 | /** |
||
93 | * Pushes on another Monolog Handler |
||
94 | 3 | * @param HandlerInterface $handler The handler instance to add on |
|
95 | 3 | * @return Notifier Returns this |
|
96 | 3 | */ |
|
97 | public function pushHandler(HandlerInterface $handler) { |
||
101 | |||
102 | /** |
||
103 | * Triggers the Monolog Logger instance to log an error to all handlers |
||
104 | 3 | * @param Exception $e The exception to use |
|
105 | 3 | * @return Notifier Returns this |
|
106 | 3 | */ |
|
107 | public function send(Exception $e) { |
||
123 | } |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.