1 | <?php namespace Peek\Api; |
||
5 | class Model implements JsonSerializable |
||
6 | { |
||
7 | /** |
||
8 | * @var array |
||
9 | */ |
||
10 | protected $attributes = []; |
||
11 | |||
12 | /** |
||
13 | * Model constructor. |
||
14 | * @param null $attributes |
||
15 | */ |
||
16 | public function __construct($attributes = null) |
||
22 | |||
23 | /** |
||
24 | * Fill the attributes |
||
25 | * @param array $attributes |
||
26 | * @return void |
||
27 | */ |
||
28 | private function fill(array $attributes) |
||
34 | |||
35 | /** |
||
36 | * Set a given attribute on the model. |
||
37 | * @param string $key |
||
38 | * @param mixed $value |
||
39 | * @return $this |
||
40 | */ |
||
41 | public function setAttribute($key, $value) |
||
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | public function jsonSerialize() |
||
55 | |||
56 | /** |
||
57 | * @return array |
||
58 | */ |
||
59 | public function toArray() |
||
63 | |||
64 | /** |
||
65 | * @param string $name |
||
66 | * @return mixed |
||
67 | */ |
||
68 | public function __get($name) |
||
72 | |||
73 | /** |
||
74 | * @param string $name |
||
75 | * @param mixed $value |
||
76 | */ |
||
77 | public function __set($name, $value) |
||
81 | |||
82 | /** |
||
83 | * Get an attribute from the $attributes array. |
||
84 | * @param string $key |
||
85 | * @return mixed |
||
86 | */ |
||
87 | public function getAttribute($key) |
||
93 | |||
94 | /** |
||
95 | * Get an attribute from the $attributes array. |
||
96 | * @param string $key |
||
97 | * @return mixed |
||
98 | */ |
||
99 | protected function getAttributeValue($key) |
||
107 | |||
108 | /** |
||
109 | * @param $key |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function __isset($key) |
||
116 | |||
117 | /** |
||
118 | * @return string |
||
119 | */ |
||
120 | public function __toString() |
||
124 | |||
125 | /** |
||
126 | * @return string |
||
127 | */ |
||
128 | public function toJson() |
||
132 | } |
||
133 |