1 | <?php namespace Arcanedev\Notify; |
||
13 | class Notify implements NotifyContract |
||
14 | { |
||
15 | /* ------------------------------------------------------------------------------------------------ |
||
16 | | Properties |
||
17 | | ------------------------------------------------------------------------------------------------ |
||
18 | */ |
||
19 | /** |
||
20 | * Session prefix name. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $sessionPrefix; |
||
25 | |||
26 | /** |
||
27 | * The session writer. |
||
28 | * |
||
29 | * @var \Arcanedev\Notify\Contracts\SessionStore |
||
30 | */ |
||
31 | private $session; |
||
32 | |||
33 | /* ------------------------------------------------------------------------------------------------ |
||
34 | | Constructor |
||
35 | | ------------------------------------------------------------------------------------------------ |
||
36 | */ |
||
37 | /** |
||
38 | * Create a new flash notifier instance. |
||
39 | * |
||
40 | * @param \Arcanedev\Notify\Contracts\SessionStore $session |
||
41 | * @param string $prefix |
||
42 | 120 | */ |
|
43 | public function __construct(SessionStore $session, $prefix) |
||
48 | |||
49 | /* ------------------------------------------------------------------------------------------------ |
||
50 | | Getters & Setters |
||
51 | | ------------------------------------------------------------------------------------------------ |
||
52 | */ |
||
53 | /** |
||
54 | * Get the notification message. |
||
55 | * |
||
56 | * @return string |
||
57 | 120 | */ |
|
58 | public function message() |
||
62 | |||
63 | /** |
||
64 | * Get the notification type. |
||
65 | * |
||
66 | * @return string |
||
67 | 120 | */ |
|
68 | public function type() |
||
72 | |||
73 | /** |
||
74 | * Get an additional stored options. |
||
75 | * |
||
76 | * @param bool $assoc |
||
77 | * |
||
78 | * @return array |
||
79 | 120 | */ |
|
80 | public function options($assoc = false) |
||
84 | |||
85 | /** |
||
86 | * Get a notification option. |
||
87 | * |
||
88 | * @param string $key |
||
89 | * @param mixed|null $default |
||
90 | * |
||
91 | * @return mixed |
||
92 | 36 | */ |
|
93 | public function option($key, $default = null) |
||
97 | |||
98 | /** |
||
99 | * Check if the flash notification has an option. |
||
100 | * |
||
101 | * @param string $key |
||
102 | 120 | * |
|
103 | * @return bool |
||
104 | 120 | */ |
|
105 | public function hasOption($key) |
||
109 | |||
110 | /** |
||
111 | * If the notification is ready to be shown. |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | public function ready() |
||
119 | |||
120 | 120 | /* ------------------------------------------------------------------------------------------------ |
|
121 | | Main Functions |
||
122 | 120 | | ------------------------------------------------------------------------------------------------ |
|
123 | 120 | */ |
|
124 | 120 | /** |
|
125 | 120 | * Flash a message. |
|
126 | 90 | * |
|
127 | * @param string $message |
||
128 | 120 | * @param string $type |
|
129 | * @param array $options |
||
130 | * |
||
131 | * @return self |
||
132 | */ |
||
133 | public function flash($message, $type = '', array $options = []) |
||
143 | |||
144 | /* ------------------------------------------------------------------------------------------------ |
||
145 | | Other Functions |
||
146 | | ------------------------------------------------------------------------------------------------ |
||
147 | */ |
||
148 | 120 | /** |
|
149 | * Prefix the name. |
||
150 | 120 | * |
|
151 | 120 | * @param string $name |
|
152 | 90 | * |
|
153 | * @return string |
||
154 | */ |
||
155 | private function getPrefixedName($name) |
||
159 | |||
160 | /** |
||
161 | * Get session value. |
||
162 | * |
||
163 | * @param string $name |
||
164 | * |
||
165 | * @return mixed |
||
166 | */ |
||
167 | private function getSession($name) |
||
173 | } |
||
174 |