1 | <?php namespace Fenos\Notifynder\Builder; |
||
23 | class NotifynderBuilder implements ArrayAccess |
||
24 | { |
||
25 | use BuilderRules; |
||
26 | |||
27 | /** |
||
28 | * @var string notification to store |
||
29 | */ |
||
30 | public $date; |
||
31 | |||
32 | /** |
||
33 | * Builder data |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $notifications = []; |
||
38 | |||
39 | /** |
||
40 | * @var Repository |
||
41 | */ |
||
42 | protected $config; |
||
43 | |||
44 | /** |
||
45 | * @var NotifynderCategory |
||
46 | */ |
||
47 | private $notifynderCategory; |
||
48 | |||
49 | /** |
||
50 | * @param NotifynderCategory $notifynderCategory |
||
51 | */ |
||
52 | function __construct(NotifynderCategory $notifynderCategory) |
||
56 | |||
57 | /** |
||
58 | * Set who will send the notification |
||
59 | * |
||
60 | * @return $this |
||
61 | */ |
||
62 | public function from() |
||
70 | |||
71 | /** |
||
72 | * Set who will receive the notification |
||
73 | * |
||
74 | * @return $this |
||
75 | */ |
||
76 | public function to() |
||
84 | |||
85 | /** |
||
86 | * Set the url of the notification |
||
87 | * |
||
88 | * @param $url |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function url($url) |
||
99 | |||
100 | /** |
||
101 | * Set expire time |
||
102 | * |
||
103 | * @param $datetime |
||
104 | * @return $this |
||
105 | */ |
||
106 | public function expire($datetime) |
||
113 | |||
114 | /** |
||
115 | * Set Category and covert it, to the id |
||
116 | * if name of it given |
||
117 | * |
||
118 | * @param $category |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function category($category) |
||
132 | |||
133 | /** |
||
134 | * Set extra value |
||
135 | * |
||
136 | * @param $extra |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function extra(array $extra = []) |
||
149 | |||
150 | /** |
||
151 | * Build the array with the builder inside |
||
152 | * a Closure, it has more flexibility for |
||
153 | * the generation of your array |
||
154 | * |
||
155 | * |
||
156 | * @param callable|Closure $closure |
||
157 | * @return array|false |
||
158 | * @throws NotificationBuilderException |
||
159 | */ |
||
160 | public function raw(Closure $closure) |
||
170 | |||
171 | /** |
||
172 | * Loop the datas for create |
||
173 | * multi notifications array |
||
174 | * |
||
175 | * @param $dataToIterate |
||
176 | * @param Closure $builder |
||
177 | * @return $this |
||
178 | * @throws NotificationBuilderException |
||
179 | */ |
||
180 | public function loop($dataToIterate, Closure $builder) |
||
199 | |||
200 | /** |
||
201 | * Compose the builder to |
||
202 | * the array |
||
203 | * |
||
204 | * @throws NotificationBuilderException |
||
205 | * @return mixed |
||
206 | */ |
||
207 | public function toArray() |
||
240 | |||
241 | /** |
||
242 | * Refresh the state of the notifications |
||
243 | */ |
||
244 | public function refresh() |
||
250 | |||
251 | /** |
||
252 | * @param $var |
||
253 | * @return bool |
||
254 | */ |
||
255 | protected function isIterable($var) |
||
259 | |||
260 | /** |
||
261 | * It set the entity who will do |
||
262 | * the action of receive or |
||
263 | * send |
||
264 | * |
||
265 | * @param $from |
||
266 | * @param $property |
||
267 | * @return array |
||
268 | */ |
||
269 | protected function setEntityAction($from, $property) |
||
287 | |||
288 | /** |
||
289 | * If the values passed are 2 or more, |
||
290 | * it means that you spefied the entity |
||
291 | * over then the id |
||
292 | * |
||
293 | * @param array $info |
||
294 | * @return bool |
||
295 | */ |
||
296 | protected function hasEntity(array $info) |
||
300 | |||
301 | /** |
||
302 | * Set date on the array |
||
303 | */ |
||
304 | protected function setDate() |
||
311 | |||
312 | /** |
||
313 | * @return string |
||
314 | */ |
||
315 | protected function getDate() |
||
319 | |||
320 | /** |
||
321 | * Set builder Data |
||
322 | * |
||
323 | * @param $field |
||
324 | * @param $data |
||
325 | */ |
||
326 | public function setBuilderData($field, $data) |
||
330 | |||
331 | |||
332 | /** |
||
333 | * @param mixed $offset |
||
334 | * @return bool |
||
335 | */ |
||
336 | public function offsetExists($offset) |
||
340 | |||
341 | |||
342 | /** |
||
343 | * @param mixed $offset |
||
344 | * @return mixed |
||
345 | */ |
||
346 | public function offsetGet($offset) |
||
350 | |||
351 | |||
352 | /** |
||
353 | * @param mixed $offset |
||
354 | * @param mixed $value |
||
355 | */ |
||
356 | public function offsetSet($offset, $value) |
||
367 | |||
368 | /** |
||
369 | * @param Repository $config |
||
370 | */ |
||
371 | public function setConfig(Repository $config) |
||
375 | |||
376 | /** |
||
377 | * @param mixed $offset |
||
378 | * @return null |
||
379 | */ |
||
380 | public function offsetUnset($offset) |
||
384 | } |
||
385 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.