1 | <?php |
||
17 | class Model implements \JsonSerializable { |
||
18 | |||
19 | /** |
||
20 | * The model's attributes |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $attributes = []; |
||
25 | |||
26 | /** |
||
27 | * The available object keys |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $fillable = []; |
||
32 | |||
33 | /** |
||
34 | * Instance of the master Pinterest class |
||
35 | * |
||
36 | * @var Pinterest |
||
37 | */ |
||
38 | protected $master; |
||
39 | |||
40 | /** |
||
41 | * Create a new model instance |
||
42 | * |
||
43 | * @param Pinterest $master |
||
44 | * @param mixed $modeldata |
||
45 | */ |
||
46 | 31 | public function __construct(Pinterest $master, $modeldata = null) |
|
58 | |||
59 | /** |
||
60 | * Get the model's attribute |
||
61 | * |
||
62 | * @access public |
||
63 | * @param string $key |
||
64 | * @return mixed |
||
65 | */ |
||
66 | 19 | public function __get($key) |
|
70 | |||
71 | /** |
||
72 | * Set the model's attribute |
||
73 | * |
||
74 | * @access public |
||
75 | * @param string $key |
||
76 | * @param mixed $value |
||
77 | * @throws Exceptions\PinterestException |
||
78 | * @return void |
||
79 | */ |
||
80 | public function __set($key, $value) |
||
88 | |||
89 | /** |
||
90 | * Check if the model's attribute is set |
||
91 | * |
||
92 | * @param $key |
||
93 | * @return bool |
||
94 | */ |
||
95 | 1 | public function __isset($key) |
|
99 | |||
100 | /** |
||
101 | * Fill the attributes |
||
102 | * |
||
103 | * @access private |
||
104 | * @param array $attributes |
||
105 | * @return void |
||
106 | */ |
||
107 | 31 | private function fill(array $attributes) |
|
115 | |||
116 | /** |
||
117 | * Check if the key is fillable |
||
118 | * |
||
119 | * @access public |
||
120 | * @param string $key |
||
121 | * @return boolean |
||
122 | */ |
||
123 | 31 | public function isFillable($key) |
|
127 | |||
128 | /** |
||
129 | * Convert the model instance to an array |
||
130 | * |
||
131 | * @access public |
||
132 | * @return array |
||
133 | */ |
||
134 | 4 | public function toArray() |
|
144 | |||
145 | /** |
||
146 | * Convert the model instance to JSON |
||
147 | * |
||
148 | * @access public |
||
149 | * @return string |
||
150 | */ |
||
151 | 1 | public function toJson() |
|
155 | |||
156 | /** |
||
157 | * Convert the object into something JSON serializable. |
||
158 | * |
||
159 | * @access public |
||
160 | * @return array |
||
161 | */ |
||
162 | public function jsonSerialize() |
||
166 | |||
167 | /** |
||
168 | * Convert the model to its string representation |
||
169 | * |
||
170 | * @access public |
||
171 | * @return string |
||
172 | */ |
||
173 | public function __toString() |
||
177 | } |