1 | <?php |
||
14 | class Records |
||
15 | { |
||
16 | const MAX_GET_RECORDS = 500; |
||
17 | const MAX_POST_RECORDS = 100; |
||
18 | |||
19 | /** |
||
20 | * @var Client |
||
21 | */ |
||
22 | private $client; |
||
23 | |||
24 | 1 | public function __construct(Client $client) |
|
28 | |||
29 | /** |
||
30 | * Get records |
||
31 | * https://cybozudev.zendesk.com/hc/ja/articles/202331474#step2 |
||
32 | * |
||
33 | * @param integer $appId |
||
34 | * @param string $query |
||
35 | * @param integer $guestSpaceId |
||
36 | * @param boolean $totalCount |
||
37 | * @param array|null $fields |
||
38 | * @return array |
||
39 | */ |
||
40 | 3 | public function get($appId, $query = '', $guestSpaceId = null, $totalCount = true, array $fields = null) |
|
54 | |||
55 | /** |
||
56 | * Get all records |
||
57 | * |
||
58 | * @param integer $appId |
||
59 | * @param string $query |
||
60 | * @param integer $guestSpaceId |
||
61 | * @param array|null $fields |
||
62 | * @return array |
||
63 | */ |
||
64 | 1 | public function all($appId, $query = '', $guestSpaceId = null, array $fields = null) |
|
95 | |||
96 | /** |
||
97 | * @param integer $appId |
||
98 | * @param string $query |
||
99 | * @param integer $guestSpaceId |
||
100 | * @param array|null $fields |
||
101 | * @param integer $totalCount |
||
102 | * @return \Closure |
||
103 | */ |
||
104 | 1 | private function createGetRequestsCallback($appId, $query, $guestSpaceId, $fields, $totalCount) |
|
127 | |||
128 | /** |
||
129 | * Post records |
||
130 | * https://cybozudev.zendesk.com/hc/ja/articles/202166160#step2 |
||
131 | * |
||
132 | * @param integer $appId |
||
133 | * @param array $records |
||
134 | * @param integer $guestSpaceId |
||
135 | * @return array |
||
136 | */ |
||
137 | 2 | public function post($appId, array $records, $guestSpaceId = null) |
|
145 | |||
146 | /** |
||
147 | * Put records |
||
148 | * https://cybozudev.zendesk.com/hc/ja/articles/201941784#step2 |
||
149 | * |
||
150 | * @param integer $appId |
||
151 | * @param array $records |
||
152 | * @param integer $guestSpaceId |
||
153 | * @return array |
||
154 | */ |
||
155 | 1 | public function put($appId, array $records, $guestSpaceId = null) |
|
163 | |||
164 | /** |
||
165 | * Delete records |
||
166 | * https://cybozudev.zendesk.com/hc/ja/articles/201941794 |
||
167 | * |
||
168 | * @param integer $appId |
||
169 | * @param array $ids |
||
170 | * @param integer $guestSpaceId |
||
171 | * @param array $revisions |
||
172 | * @return array |
||
173 | */ |
||
174 | 1 | public function delete($appId, array $ids, $guestSpaceId = null, array $revisions = []) |
|
185 | |||
186 | /** |
||
187 | * Put records status |
||
188 | * https://cybozudev.zendesk.com/hc/ja/articles/204791550#anchor_changeRecordStatusBulk |
||
189 | * |
||
190 | * @param integer $appId |
||
191 | * @param array $records |
||
192 | * @param integer $guestSpaceId |
||
193 | * @return array |
||
194 | */ |
||
195 | 1 | public function putStatus($appId, array $records, $guestSpaceId = null) |
|
203 | } |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: