1 | <?php |
||
18 | abstract class DataBaseModel implements DataBaseModelInterface |
||
19 | { |
||
20 | protected $tableName; |
||
21 | protected $dataBaseQuery; |
||
22 | protected $arrayField; |
||
23 | |||
24 | /** |
||
25 | * This is a constructor; a default method that will be called automatically during class instantiation. |
||
26 | */ |
||
27 | 51 | public function __construct() |
|
28 | { |
||
29 | 51 | $this->tableName = self::getClassName(); |
|
30 | 51 | $this->dataBaseQuery = new DataBaseQuery(); |
|
31 | 51 | $this->arrayField['id'] = 0; |
|
32 | 51 | } |
|
33 | |||
34 | /** |
||
35 | * The magic setter method. |
||
36 | * |
||
37 | * @param $properties |
||
38 | * @param $values |
||
39 | * |
||
40 | * @return array associative array properties |
||
41 | */ |
||
42 | public function __set($properties, $values) |
||
43 | { |
||
44 | $this->arrayField[$properties] = $values; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * The magic getter method. |
||
49 | * |
||
50 | * @param $properties |
||
51 | * |
||
52 | * @return array key |
||
53 | */ |
||
54 | public function __get($properties) |
||
58 | |||
59 | /** |
||
60 | * This method gets all the record from a particular table |
||
61 | * by accessing the read method from the DataBaseQuery class. |
||
62 | * |
||
63 | * |
||
64 | * @return associative array |
||
65 | */ |
||
66 | 6 | public static function getAll($dbConn = null) |
|
80 | |||
81 | /** |
||
82 | * This method either create or update record in a database table |
||
83 | * by calling either the read method or create method in the |
||
84 | * DataBaseQuery class. |
||
85 | * |
||
86 | * @throws NoRecordUpdateException |
||
87 | * @throws EmptyArrayException |
||
88 | * @throws NoRecordCreatedException |
||
89 | * |
||
90 | * @return bool true or false; |
||
91 | */ |
||
92 | public function save($dbConn = null) |
||
123 | |||
124 | /** |
||
125 | * This method find a record by id. |
||
126 | * |
||
127 | * @param $id |
||
128 | * |
||
129 | * @throws ArgumentNumberIncorrectException |
||
130 | * @throws ArgumentNotFoundException |
||
131 | * |
||
132 | * @return object |
||
133 | */ |
||
134 | 6 | public static function findById($id) |
|
152 | |||
153 | /** |
||
154 | * This method find a record by id and returns |
||
155 | * all the data present in the id. |
||
156 | * |
||
157 | * |
||
158 | * @return associative array |
||
159 | */ |
||
160 | public function getById() |
||
168 | |||
169 | /** |
||
170 | * This method delete a row from the table by the row id. |
||
171 | * |
||
172 | * @param $id |
||
173 | * |
||
174 | * @throws ArgumentNumberIncorrectException; |
||
175 | * @throws ArgumentNotFoundException; |
||
176 | * |
||
177 | * @return bool true |
||
178 | */ |
||
179 | 9 | public static function destroy($id, $dbConn = null) |
|
199 | |||
200 | 51 | public static function getClassName() |
|
206 | |||
207 | /** |
||
208 | * This method check if the argument passed to this function is an array. |
||
209 | * |
||
210 | * @param $arrayOfRecord |
||
211 | * |
||
212 | * @return bool true |
||
213 | */ |
||
214 | 6 | public function checkIfRecordIsEmpty($arrayOfRecord) |
|
222 | |||
223 | /** |
||
224 | * This method throws exception if record is not updated succesfully. |
||
225 | * |
||
226 | * @throws $NoRecordUpdatedException |
||
227 | */ |
||
228 | 3 | public function throwNoRecordUpdatedException() |
|
233 | |||
234 | /** |
||
235 | * This method throws exception if data did not match any record. |
||
236 | * |
||
237 | * @throws $EmptyArrayException |
||
238 | */ |
||
239 | 3 | public function throwEmptyArrayException() |
|
244 | |||
245 | /** |
||
246 | * This method throws exception if record did not create successfully. |
||
247 | * |
||
248 | * @throws $NoRecordCreatedException |
||
249 | */ |
||
250 | 3 | public function throwNoRecordCreatedException() |
|
255 | |||
256 | /** |
||
257 | * This method throws exception if no data is found. |
||
258 | * |
||
259 | * @throws $NoDataFoundException |
||
260 | */ |
||
261 | 3 | public static function throwNoDataFoundException() |
|
266 | } |
||
267 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.