1 | <?php |
||
20 | class BaseType |
||
21 | { |
||
22 | /** |
||
23 | * @var Collection |
||
24 | */ |
||
25 | protected $attributes; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $map = []; |
||
31 | |||
32 | /** |
||
33 | * BaseType constructor. |
||
34 | * |
||
35 | * @param $attributes |
||
36 | */ |
||
37 | 6 | public function __construct($attributes) |
|
38 | { |
||
39 | 6 | $this->attributes = $this->build($attributes); |
|
40 | 6 | } |
|
41 | |||
42 | /** |
||
43 | * @param array $attributes |
||
44 | * |
||
45 | * @return Collection |
||
46 | */ |
||
47 | 6 | private function build(array $attributes = []) |
|
65 | |||
66 | /** |
||
67 | * @param array|string $json |
||
68 | * |
||
69 | * @return static |
||
70 | */ |
||
71 | 3 | public static function create($json) |
|
72 | { |
||
73 | 3 | return new static(is_array($json) ? $json : json_decode($json, true)); |
|
74 | } |
||
75 | |||
76 | 3 | public function get($key) |
|
80 | |||
81 | 1 | public function toArray() |
|
99 | |||
100 | 1 | public function toJson() |
|
104 | |||
105 | 3 | public function __call($name, $arguments) |
|
114 | } |