1 | <?php |
||
28 | class Notification extends Controller |
||
29 | { |
||
30 | /** |
||
31 | * Notifier. |
||
32 | * |
||
33 | * @var Notifier |
||
34 | */ |
||
35 | protected $notifier; |
||
36 | |||
37 | /** |
||
38 | * User. |
||
39 | * |
||
40 | * @var User |
||
41 | */ |
||
42 | protected $user; |
||
43 | |||
44 | /** |
||
45 | * Filesystem. |
||
46 | * |
||
47 | * @var Filesystem |
||
48 | */ |
||
49 | protected $fs; |
||
50 | |||
51 | /** |
||
52 | * Server. |
||
53 | * |
||
54 | * @var Server |
||
55 | */ |
||
56 | protected $server; |
||
57 | |||
58 | /** |
||
59 | * Async. |
||
60 | * |
||
61 | * @var Async |
||
62 | */ |
||
63 | protected $async; |
||
64 | |||
65 | /** |
||
66 | * Logger. |
||
67 | * |
||
68 | * @var LoggerInterface |
||
69 | */ |
||
70 | protected $logger; |
||
71 | |||
72 | /** |
||
73 | * Constructor. |
||
74 | * |
||
75 | * @param Notifier $notifier |
||
76 | * @param Server $server |
||
77 | * @param Async $async |
||
78 | * @param LoggerInterface $logger |
||
79 | */ |
||
80 | public function __construct(Notifier $notifier, Server $server, Async $async, LoggerInterface $logger) |
||
89 | |||
90 | /** |
||
91 | * @api {get} /api/v1/notification Get notifications |
||
92 | * @apiVersion 1.0.0 |
||
93 | * @apiName get |
||
94 | * @apiGroup App\Notification |
||
95 | * @apiPermission none |
||
96 | * @apiDescription Fetch my nofitifications |
||
97 | * |
||
98 | * @apiExample (cURL) exmaple: |
||
99 | * curl -XGET "https://SERVER/api/v1/user/notification" |
||
100 | * |
||
101 | * @apiSuccessExample {string} Success-Response: |
||
102 | * HTTP/1.1 200 OK |
||
103 | * { |
||
104 | * "status": 200, |
||
105 | * "data": [{ |
||
106 | * "message": "Hi there, this is a notification" |
||
107 | * }] |
||
108 | * } |
||
109 | */ |
||
110 | public function get(): Response |
||
128 | |||
129 | /** |
||
130 | * @api {delete} /api/v1/notification Delete notification |
||
131 | * @apiVersion 1.0.0 |
||
132 | * @apiName get |
||
133 | * @apiGroup App\Notification |
||
134 | * @apiPermission none |
||
135 | * @apiDescription Fetch my nofitifications |
||
136 | * |
||
137 | * @apiExample (cURL) exmaple: |
||
138 | * curl -XGET "https://SERVER/api/v1/user/notification" |
||
139 | * |
||
140 | * @apiSuccessExample {string} Success-Response: |
||
141 | * HTTP/1.1 204 No Content |
||
142 | */ |
||
143 | public function delete(string $id): Response |
||
149 | |||
150 | /** |
||
151 | * @api {post} /api/v1/user/notification/broadcast Post a notification to all users (or to a bunch of users) |
||
152 | * @apiVersion 1.0.0 |
||
153 | * @apiName get |
||
154 | * @apiGroup App\Notification |
||
155 | * @apiPermission admin |
||
156 | * @apiDescription Send notification |
||
157 | * |
||
158 | * @apiExample (cURL) exmaple: |
||
159 | * curl -XPOST "https://SERVER/api/v1/user/notification/broadcast" |
||
160 | * |
||
161 | * @apiSuccessExample {string} Success-Response: |
||
162 | * HTTP/1.1 204 No Content |
||
163 | */ |
||
164 | public function post(array $receiver, string $subject, string $body): Response |
||
171 | |||
172 | /** |
||
173 | * @api {post} /api/v1/notification/broadcast Post a notification to all users (or to a bunch of users) |
||
174 | * @apiVersion 1.0.0 |
||
175 | * @apiName get |
||
176 | * @apiGroup App\Notification |
||
177 | * @apiPermission admin |
||
178 | * @apiDescription Send notification |
||
179 | * |
||
180 | * @apiExample (cURL) exmaple: |
||
181 | * curl -XPOST "https://SERVER/api/v1/user/notification/broadcast" |
||
182 | * |
||
183 | * @apiSuccessExample {string} Success-Response: |
||
184 | * HTTP/1.1 204 No Content |
||
185 | */ |
||
186 | public function postBroadcast(string $subject, string $body): Response |
||
200 | |||
201 | /** |
||
202 | * @api {post} /api/v1/notification/mail Send a normal mail message |
||
203 | * @apiVersion 1.0.0 |
||
204 | * @apiName get |
||
205 | * @apiGroup App\Notification |
||
206 | * @apiPermission none |
||
207 | * @apiDescription Send mail |
||
208 | * |
||
209 | * @apiExample (cURL) exmaple: |
||
210 | * curl -XGET "https://SERVER/api/v1/user/notification" |
||
211 | * |
||
212 | * @apiSuccessExample {string} Success-Response: |
||
213 | * HTTP/1.1 204 No Content |
||
214 | */ |
||
215 | public function postMail(array $receiver, string $subject, string $body) |
||
226 | |||
227 | /** |
||
228 | * @api {post} /api/v1/node/subscribe Subscribe for node updates |
||
229 | * @apiVersion 1.0.0 |
||
230 | * @apiName get |
||
231 | * @apiGroup App\Notification |
||
232 | * @apiPermission none |
||
233 | * @apiDescription Receive node updates |
||
234 | * @apiUse _getNodes |
||
235 | * @apiUse _multiError |
||
236 | * |
||
237 | * @apiExample (cURL) exmaple: |
||
238 | * curl -XPOST "https://SERVER/api/v1/node/subscribe" |
||
239 | * |
||
240 | * @apiSuccessExample {string} Success-Response: |
||
241 | * HTTP/1.1 204 No Content |
||
242 | * |
||
243 | * @param null|mixed $id |
||
244 | * @param null|mixed $p |
||
245 | */ |
||
246 | public function postSubscribe($id = null, $p = null, bool $subscribe = true) |
||
279 | } |
||
280 |
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.