Completed
Push — version-4 ( f72e7e...501c45 )
by
unknown
02:53
created

Notification::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
namespace Fenos\Notifynder\Builder;
3
4
use JsonSerializable;
5
use Illuminate\Contracts\Support\Arrayable;
6
use Illuminate\Contracts\Support\Jsonable;
7
use Illuminate\Support\Arr;
8
9
class Notification implements Arrayable, Jsonable, JsonSerializable
10
{
11
    protected $attributes = [];
12
13
    public function attributes()
14
    {
15
        return $this->attributes;
16
    }
17
18
    public function attribute($key, $default = null)
19
    {
20
        return $this->get($key, $default);
21
    }
22
23
    public function get($key, $default = null)
24
    {
25
        return Arr::get($this->attributes, $key, $default);
26
    }
27
28
    public function set($key, $value)
29
    {
30
        Arr::set($this->attributes, $key, $value);
31
    }
32
33
    public function __get($key)
34
    {
35
        return $this->get($key);
36
    }
37
38
    public function __set($key, $value)
39
    {
40
        $this->set($key, $value);
41
    }
42
43
    public function toJson($options = 0)
44
    {
45
        return json_encode($this->jsonSerialize(), $options);
46
    }
47
48
    public function jsonSerialize()
49
    {
50
        return $this->toArray();
51
    }
52
53
    public function toArray()
54
    {
55
        return array_map(function ($value) {
56
            return $value instanceof Arrayable ? $value->toArray() : $value;
57
        }, $this->attributes);
58
    }
59
60
    public function __toString()
61
    {
62
        return $this->toJson();
63
    }
64
}