1 | <?php |
||
13 | abstract class AbstractRow implements JsonSerializable |
||
14 | { |
||
15 | protected $table; |
||
16 | |||
17 | /** |
||
18 | * Constructor. |
||
19 | * |
||
20 | * @param Table $table |
||
21 | */ |
||
22 | public function __construct(Table $table) |
||
26 | |||
27 | /** |
||
28 | * Returns the table associated with this row. |
||
29 | * |
||
30 | * @return Table |
||
31 | */ |
||
32 | public function getTable() |
||
36 | |||
37 | /** |
||
38 | * Returns the database associated with this row. |
||
39 | * |
||
40 | * @return SimpleCrud |
||
41 | */ |
||
42 | public function getDatabase() |
||
46 | |||
47 | /** |
||
48 | * @see JsonSerializable |
||
49 | * |
||
50 | * @return array |
||
51 | */ |
||
52 | public function jsonSerialize() |
||
56 | |||
57 | /** |
||
58 | * Magic method to stringify the values. |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public function __toString() |
||
66 | |||
67 | /** |
||
68 | * Converts this object into an array. |
||
69 | * |
||
70 | * @param array $bannedEntities |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | abstract public function toArray(array $bannedEntities = []); |
||
75 | |||
76 | /** |
||
77 | * Magic method to return properties. |
||
78 | * |
||
79 | * @param string $name |
||
80 | * |
||
81 | * @return mixed |
||
82 | */ |
||
83 | abstract public function __get($name); |
||
84 | |||
85 | /** |
||
86 | * Magic method to edit a property. |
||
87 | * |
||
88 | * @param string $name |
||
89 | * @param mixed $value |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | abstract public function __set($name, $value); |
||
94 | |||
95 | /** |
||
96 | * Deletes the row(s) in the database. |
||
97 | * |
||
98 | * @return self |
||
99 | */ |
||
100 | public function delete() |
||
114 | |||
115 | /** |
||
116 | * Magic method to execute queries. |
||
117 | * |
||
118 | * @param string $name |
||
119 | */ |
||
120 | public function __call($name, $arguments) |
||
140 | } |
||
141 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: