1 | <?php |
||
10 | class ClientLocal implements RequestsInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var BaseTableGateway[] |
||
14 | */ |
||
15 | protected $tableGateways = []; |
||
16 | |||
17 | /** |
||
18 | * @var Connection |
||
19 | */ |
||
20 | protected $connection = null; |
||
21 | |||
22 | public function __construct($connection) |
||
26 | |||
27 | /** |
||
28 | * Get a table gateway for the given table name |
||
29 | * |
||
30 | * @param $tableName |
||
31 | * |
||
32 | * @return RelationalTableGatewayWithConditions |
||
33 | */ |
||
34 | protected function getTableGateway($tableName) |
||
42 | |||
43 | public function getEntries($tableName, array $options = []) |
||
49 | |||
50 | public function getEntry($id, $tableName, array $options = []) |
||
56 | |||
57 | /** |
||
58 | * @inheritDoc |
||
59 | */ |
||
60 | public function fetchTables() |
||
64 | |||
65 | /** |
||
66 | * @inheritDoc |
||
67 | */ |
||
68 | public function fetchTableInfo($tableName) |
||
72 | |||
73 | /** |
||
74 | * @inheritDoc |
||
75 | */ |
||
76 | public function fetchColumns($tableName) |
||
80 | |||
81 | /** |
||
82 | * @inheritDoc |
||
83 | */ |
||
84 | public function fetchColumnInfo($tableName, $columnName) |
||
88 | |||
89 | /** |
||
90 | * @inheritDoc |
||
91 | */ |
||
92 | public function fetchItems($tableName = null, $conditions = []) |
||
112 | |||
113 | /** |
||
114 | * @inheritDoc |
||
115 | */ |
||
116 | public function fetchItem($tableName, $itemID) |
||
120 | |||
121 | /** |
||
122 | * @inheritDoc |
||
123 | */ |
||
124 | public function fetchGroups() |
||
128 | |||
129 | /** |
||
130 | * @inheritDoc |
||
131 | */ |
||
132 | public function fetchGroupInfo($groupID) |
||
136 | |||
137 | /** |
||
138 | * @inheritDoc |
||
139 | */ |
||
140 | public function fetchGroupPrivileges($groupID) |
||
144 | |||
145 | /** |
||
146 | * @inheritDoc |
||
147 | */ |
||
148 | public function fetchFiles() |
||
152 | |||
153 | /** |
||
154 | * @inheritDoc |
||
155 | */ |
||
156 | public function fetchFileInfo($fileID) |
||
160 | |||
161 | /** |
||
162 | * @inheritDoc |
||
163 | */ |
||
164 | public function fetchSettings() |
||
168 | |||
169 | /** |
||
170 | * @inheritDoc |
||
171 | */ |
||
172 | public function fetchSettingCollection($collectionName) |
||
176 | |||
177 | } |
||
178 |
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.