1 | <?php |
||
7 | class Notifier |
||
8 | { |
||
9 | |||
10 | /** |
||
11 | * Added notifications |
||
12 | * |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $notifications = []; |
||
16 | |||
17 | /** |
||
18 | * Added notifications |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $options = []; |
||
23 | |||
24 | /** |
||
25 | * Illuminate Session |
||
26 | * |
||
27 | * @var \Illuminate\Session\SessionManager |
||
28 | */ |
||
29 | protected $session; |
||
30 | |||
31 | /** |
||
32 | * Constructor |
||
33 | * |
||
34 | * @param \Illuminate\Session\SessionManager $session |
||
35 | * |
||
36 | * @internal param \Illuminate\Session\SessionManager $session |
||
37 | */ |
||
38 | public function __construct(SessionManager $session) |
||
42 | |||
43 | /** |
||
44 | * Render all the notifications' script to insert into script tag |
||
45 | * |
||
46 | * @return string |
||
47 | * |
||
48 | */ |
||
49 | public function render() : string |
||
65 | |||
66 | /** |
||
67 | * Render the script of given notification to insert into script tag |
||
68 | * |
||
69 | * @param $notification |
||
70 | * @return string |
||
71 | */ |
||
72 | public function renderNotification($notification): string |
||
98 | |||
99 | /** |
||
100 | * Add a notification |
||
101 | * |
||
102 | * @param string $type Could be error, info, success, or warning. |
||
103 | * @param string $message The notification's message |
||
104 | * @param string $title The notification's title |
||
105 | * @param array $options |
||
106 | * @param bool $onlyNextRequest if true(default), se the notification in session only for the next request |
||
107 | * |
||
108 | */ |
||
109 | public function add($type, $message, $title = null, array $options = [], bool $onlyNextRequest=true) |
||
128 | |||
129 | /** |
||
130 | * Shortcut for adding an info notification |
||
131 | * |
||
132 | * @param string $message The notification's message |
||
133 | * @param string $title The notification's title |
||
134 | * @param array $options |
||
135 | */ |
||
136 | public function info($message, $title = null, array $options = []) |
||
140 | |||
141 | /** |
||
142 | * Shortcut for adding an error notification |
||
143 | * |
||
144 | * @param string $message The notification's message |
||
145 | * @param string $title The notification's title |
||
146 | * @param array $options |
||
147 | */ |
||
148 | public function error($message, $title = null, array $options = []) |
||
152 | |||
153 | /** |
||
154 | * Shortcut for adding a warning notification |
||
155 | * |
||
156 | * @param string $message The notification's message |
||
157 | * @param string $title The notification's title |
||
158 | * @param array $options |
||
159 | */ |
||
160 | public function warning($message, $title = null, array $options = []) |
||
164 | |||
165 | /** |
||
166 | * Shortcut for adding a success notification |
||
167 | * |
||
168 | * @param string $message The notification's message |
||
169 | * @param string $title The notification's title |
||
170 | * @param array $options |
||
171 | */ |
||
172 | public function success($message, $title = null, array $options = []) |
||
176 | |||
177 | /** |
||
178 | * Clear all notifications |
||
179 | * @param bool $withSession if true (default) clean notifications in session too. |
||
180 | */ |
||
181 | public function clear(bool $withSession = true) |
||
189 | } |
||
190 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.