1 | <?php |
||
13 | abstract class AbstractEntity implements EntityInterface, \ArrayAccess |
||
14 | { |
||
15 | /** |
||
16 | * The data for this AbstractEntity |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | private $data = []; |
||
21 | |||
22 | /** |
||
23 | * Create a new AbstractEntity based on the given $input array. |
||
24 | * |
||
25 | * @param array $input The data for the EntityInterface. |
||
26 | */ |
||
27 | public function __construct(array $input = []) |
||
36 | |||
37 | /** |
||
38 | * Get an AbstractEntity property. |
||
39 | * |
||
40 | * @param string $name The name of the property. |
||
41 | * |
||
42 | * @return mixed |
||
43 | * |
||
44 | * @throws UndefinedPropertyException Throw if this class does not contain the $name'd property. |
||
45 | */ |
||
46 | final public function __get(string $name) |
||
55 | |||
56 | /** |
||
57 | * Allows for getX() method calls. |
||
58 | * |
||
59 | * @param string $name The name of the method being called. |
||
60 | * @param array $arguments The arguments being passed to the method. This parameter is unused. |
||
61 | * |
||
62 | * @return mixed |
||
63 | * |
||
64 | * @throws \BadMethodCallException Thrown if the property being accessed does not exist. |
||
65 | */ |
||
66 | final public function __call(string $name, array $arguments = []) |
||
82 | |||
83 | /** |
||
84 | * Create an array of new AbstractEntity based on the given $input arrays |
||
85 | * |
||
86 | * @param array[] $inputs The value to be filtered. |
||
87 | * |
||
88 | * @return AbstractEntity[] |
||
89 | */ |
||
90 | final public static function fromArrays(array $inputs) : array |
||
101 | |||
102 | /** |
||
103 | * Create a new AbstractEntity based on the given $input array |
||
104 | * |
||
105 | * @param array $input The data for the AbstractEntity. |
||
106 | * |
||
107 | * @return EntityInterface |
||
108 | */ |
||
109 | final public static function fromArray(array $input = null) : EntityInterface |
||
113 | |||
114 | /** |
||
115 | * Returns whether the requested index exists |
||
116 | * |
||
117 | * @param string $offset The index being checked. |
||
118 | * |
||
119 | * @return boolean |
||
120 | */ |
||
121 | final public function offsetExists($offset) //@codingStandardsIgnoreLine Ingore missing type-hint |
||
125 | |||
126 | /** |
||
127 | * Returns the value at the specified index. |
||
128 | * |
||
129 | * @param string $offset The index with the value. |
||
130 | * |
||
131 | * @return mixed |
||
132 | */ |
||
133 | final public function offsetGet($offset) //@codingStandardsIgnoreLine Ingore missing type-hint |
||
137 | |||
138 | /** |
||
139 | * Sets the value at the specified index to newval |
||
140 | * |
||
141 | * @param string $offset The index being get. |
||
142 | * @param mixed $value The new value for the index. |
||
143 | * |
||
144 | * @return void |
||
145 | * |
||
146 | * @throws NotAllowedException Ensure this object is immutable. |
||
147 | */ |
||
148 | final public function offsetSet($offset, $value) //@codingStandardsIgnoreLine Ingore missing type-hint |
||
153 | |||
154 | /** |
||
155 | * Unsets the value at the specified index |
||
156 | * |
||
157 | * @param string $offset The index being unset. |
||
158 | * |
||
159 | * @return void |
||
160 | * |
||
161 | * @throws NotAllowedException Ensure this object is immutable. |
||
162 | */ |
||
163 | final public function offsetUnset($offset) //@codingStandardsIgnoreLine Ingore missing type-hint |
||
168 | |||
169 | /** |
||
170 | * Returns an array of filters suitable for use with \Chadicus\Marvel\Api\Filterer::filter() |
||
171 | * |
||
172 | * @return array |
||
173 | */ |
||
174 | abstract protected function getFilters() : array; |
||
175 | } |
||
176 |