1 | <?php |
||
16 | class Notification implements Arrayable, ArrayAccess, Jsonable, JsonSerializable |
||
17 | { |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $attributes = []; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $requiredFields = [ |
||
27 | 'from_id', |
||
28 | 'to_id', |
||
29 | 'category_id', |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * Notification constructor. |
||
34 | */ |
||
35 | public function __construct() |
||
40 | |||
41 | /** |
||
42 | * @return array |
||
43 | */ |
||
44 | public function attributes() |
||
48 | |||
49 | /** |
||
50 | * @param string $key |
||
51 | * @param null|mixed $default |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function attribute($key, $default = null) |
||
58 | |||
59 | /** |
||
60 | * @param string $key |
||
61 | * @return bool |
||
62 | */ |
||
63 | public function has($key) |
||
67 | |||
68 | /** |
||
69 | * @param string $key |
||
70 | * @param null|mixed $default |
||
71 | * @return mixed |
||
72 | */ |
||
73 | public function get($key, $default = null) |
||
77 | |||
78 | /** |
||
79 | * @param string $key |
||
80 | * @param mixed $value |
||
81 | */ |
||
82 | public function set($key, $value) |
||
86 | |||
87 | /** |
||
88 | * @return bool |
||
89 | */ |
||
90 | public function isValid() |
||
100 | |||
101 | /** |
||
102 | * @param string $key |
||
103 | * @return mixed |
||
104 | */ |
||
105 | public function __get($key) |
||
109 | |||
110 | /** |
||
111 | * @param string $key |
||
112 | * @param mixed $value |
||
113 | */ |
||
114 | public function __set($key, $value) |
||
118 | |||
119 | /** |
||
120 | * @param int $options |
||
121 | * @return string |
||
122 | */ |
||
123 | public function toJson($options = 0) |
||
127 | |||
128 | /** |
||
129 | * @return array |
||
130 | */ |
||
131 | public function jsonSerialize() |
||
135 | |||
136 | /** |
||
137 | * @return array |
||
138 | */ |
||
139 | public function toArray() |
||
145 | |||
146 | /** |
||
147 | * @return array |
||
148 | */ |
||
149 | public function toDbArray() |
||
150 | { |
||
151 | $notification = $this->toArray(); |
||
152 | if (array_key_exists('extra', $notification) && is_array($notification['extra'])) { |
||
153 | $notification['extra'] = json_encode($notification['extra']); |
||
154 | } |
||
155 | |||
156 | return $notification; |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getText() |
||
171 | |||
172 | /** |
||
173 | * @return string |
||
174 | */ |
||
175 | public function toString() |
||
179 | |||
180 | /** |
||
181 | * @return string |
||
182 | */ |
||
183 | public function __toString() |
||
187 | |||
188 | /** |
||
189 | * @param string $offset |
||
190 | * @return bool |
||
191 | */ |
||
192 | public function offsetExists($offset) |
||
196 | |||
197 | /** |
||
198 | * @param string $offset |
||
199 | * @return mixed |
||
200 | */ |
||
201 | public function offsetGet($offset) |
||
205 | |||
206 | /** |
||
207 | * @param string $offset |
||
208 | * @param mixed $value |
||
209 | */ |
||
210 | public function offsetSet($offset, $value) |
||
214 | |||
215 | /** |
||
216 | * @param string $offset |
||
217 | */ |
||
218 | public function offsetUnset($offset) |
||
222 | } |
||
223 |