1 | <?php |
||
16 | abstract class BaseEntity implements Arrayable, Jsonable, ArrayAccess, JsonSerializable |
||
17 | { |
||
18 | /** |
||
19 | * Names of attributes that can be filled. |
||
20 | * |
||
21 | * @type array |
||
22 | */ |
||
23 | protected $fillable = []; |
||
24 | |||
25 | /** |
||
26 | * Entity attributes. |
||
27 | * |
||
28 | * @type array |
||
29 | */ |
||
30 | protected $attributes = []; |
||
31 | |||
32 | /** |
||
33 | * BaseEntity constructor. |
||
34 | * |
||
35 | * @param array $data |
||
36 | */ |
||
37 | public function __construct(array $data = []) |
||
41 | |||
42 | /** |
||
43 | * Fill attributes that can be filled. |
||
44 | * |
||
45 | * @param $data |
||
46 | * |
||
47 | * @return void |
||
48 | */ |
||
49 | public function fill(array $data) |
||
53 | |||
54 | /** |
||
55 | * Get the instance as an array. |
||
56 | * |
||
57 | * @return array return array representation of object. |
||
58 | */ |
||
59 | public function toArray() |
||
63 | |||
64 | /** |
||
65 | * Convert the object to its JSON representation. |
||
66 | * |
||
67 | * @param int $options |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | public function toJson($options = 0) |
||
75 | |||
76 | /** |
||
77 | * Return array with with key that can be filled. |
||
78 | * |
||
79 | * @param array $data |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | protected function filterFillable(array $data) |
||
87 | |||
88 | /** |
||
89 | * Whether a offset exists. |
||
90 | * |
||
91 | * @param mixed $offset An offset to check for. |
||
92 | * |
||
93 | * @return boolean true on success or false on failure. |
||
94 | */ |
||
95 | public function offsetExists($offset) |
||
99 | |||
100 | /** |
||
101 | * Offset to retrieve. |
||
102 | * |
||
103 | * @param mixed $offset The offset to retrieve. |
||
104 | * |
||
105 | * @return mixed Can return all value types. |
||
106 | */ |
||
107 | public function offsetGet($offset) |
||
111 | |||
112 | /** |
||
113 | * Offset to set. |
||
114 | * |
||
115 | * @param mixed $offset The offset to assign the value to. |
||
116 | * @param mixed $value The value to set. |
||
117 | * |
||
118 | * @return void |
||
119 | */ |
||
120 | public function offsetSet($offset, $value) |
||
124 | |||
125 | /** |
||
126 | * Offset to unset. |
||
127 | * |
||
128 | * @param mixed $offset The offset to unset. |
||
129 | * |
||
130 | * @return void |
||
131 | */ |
||
132 | public function offsetUnset($offset) |
||
136 | |||
137 | /** |
||
138 | * Specify data which should be serialized to JSON |
||
139 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
140 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
141 | * which is a value of any type other than a resource. |
||
142 | * @since 5.4.0 |
||
143 | */ |
||
144 | public function jsonSerialize() |
||
148 | } |
||
149 |