These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Module; |
||
3 | |||
4 | use function array_key_exists; |
||
5 | use function is_array; |
||
6 | |||
7 | /** |
||
8 | * children class to create a module with notification |
||
9 | * |
||
10 | * @since 3.3.0 |
||
11 | * |
||
12 | * @package Redaxscript |
||
13 | * @category Module |
||
14 | * @author Henry Ruhs |
||
15 | */ |
||
16 | |||
17 | class Notification extends Module |
||
18 | { |
||
19 | /** |
||
20 | * array of the notification |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | |||
25 | protected static $_notificationArray = []; |
||
26 | |||
27 | /** |
||
28 | * get the message from notification |
||
29 | * |
||
30 | * @since 3.0.0 |
||
31 | * |
||
32 | * @param string $type type of the notification |
||
33 | * |
||
34 | * @return array|null |
||
35 | */ |
||
36 | |||
37 | 3 | public function getNotification(string $type = null) : ?array |
|
38 | { |
||
39 | 3 | if (is_array(self::$_notificationArray) && array_key_exists($type, self::$_notificationArray)) |
|
40 | { |
||
41 | 1 | return self::$_notificationArray[$type]; |
|
42 | } |
||
43 | 2 | if (!$type) |
|
0 ignored issues
–
show
|
|||
44 | { |
||
45 | 1 | return self::$_notificationArray; |
|
46 | } |
||
47 | 1 | return null; |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * set the message to notification |
||
52 | * |
||
53 | * @since 3.0.0 |
||
54 | * |
||
55 | * @param string $type type of the notification |
||
56 | * @param string|array $message message of the notification |
||
57 | */ |
||
58 | |||
59 | 2 | public function setNotification(string $type = null, $message = null) : void |
|
60 | { |
||
61 | 2 | $moduleName = static::$_moduleArray['name']; |
|
62 | 2 | static::$_notificationArray[$type][$moduleName][] = $message; |
|
63 | 2 | } |
|
64 | |||
65 | /** |
||
66 | * clear the notification |
||
67 | * |
||
68 | * @since 3.0.0 |
||
69 | * |
||
70 | * @param string $type type of the notification |
||
71 | */ |
||
72 | |||
73 | 2 | public function clearNotification(string $type = null) : void |
|
74 | { |
||
75 | 2 | $moduleName = static::$_moduleArray['name']; |
|
76 | 2 | static::$_notificationArray[$type][$moduleName] = null; |
|
77 | 2 | } |
|
78 | } |
||
79 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: