1 | <?php |
||
11 | class App |
||
12 | { |
||
13 | /** |
||
14 | * @var Client |
||
15 | */ |
||
16 | private $client; |
||
17 | |||
18 | public function __construct(Client $client) |
||
22 | |||
23 | /** |
||
24 | * Get app |
||
25 | * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1 |
||
26 | * |
||
27 | * @param integer $id |
||
28 | * @param integer $guestSpaceId |
||
29 | * @return array |
||
30 | */ |
||
31 | public function get($id, $guestSpaceId = null) |
||
39 | |||
40 | /** |
||
41 | * Get app settings |
||
42 | * https://cybozudev.zendesk.com/hc/ja/articles/204694170 |
||
43 | * |
||
44 | * @param integer $id |
||
45 | * @param integer $guestSpaceId |
||
46 | * @param string $lang |
||
47 | * @return array |
||
48 | */ |
||
49 | public function getSettings($id, $guestSpaceId = null, $lang = 'default') |
||
57 | |||
58 | /** |
||
59 | * Get app forms |
||
60 | * https://cybozudev.zendesk.com/hc/ja/articles/201941834#step1 |
||
61 | * |
||
62 | * @param integer $id |
||
63 | * @param integer $guestSpaceId |
||
64 | * @return array |
||
65 | */ |
||
66 | public function getForm($id, $guestSpaceId = null) |
||
74 | |||
75 | /** |
||
76 | * Get app form fields |
||
77 | * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_fields |
||
78 | * |
||
79 | * @param integer $id |
||
80 | * @param integer $guestSpaceId |
||
81 | * @param string $lang |
||
82 | * @return array |
||
83 | */ |
||
84 | public function getFields($id, $guestSpaceId = null, $lang = 'default') |
||
92 | |||
93 | /** |
||
94 | * Get app form layout |
||
95 | * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_layout |
||
96 | * |
||
97 | * @param integer $id |
||
98 | * @param integer $guestSpaceId |
||
99 | * @param string $lang |
||
100 | * @return array |
||
101 | */ |
||
102 | public function getLayout($id, $guestSpaceId = null, $lang = 'default') |
||
110 | |||
111 | /** |
||
112 | * Get app views |
||
113 | * https://cybozudev.zendesk.com/hc/ja/articles/204529784 |
||
114 | * |
||
115 | * @param integer $id |
||
116 | * @param integer $guestSpaceId |
||
117 | * @param string $lang |
||
118 | * @return array |
||
119 | */ |
||
120 | public function getViews($id, $guestSpaceId = null, $lang = 'default') |
||
128 | |||
129 | /** |
||
130 | * Get app acl |
||
131 | * https://cybozudev.zendesk.com/hc/ja/articles/204529754 |
||
132 | * |
||
133 | * @param integer $id |
||
134 | * @param integer $guestSpaceId |
||
135 | * @param string $lang |
||
136 | * @return array |
||
137 | */ |
||
138 | public function getAcl($id, $guestSpaceId = null, $lang = 'default') |
||
146 | |||
147 | /** |
||
148 | * Get record acl |
||
149 | * https://cybozudev.zendesk.com/hc/ja/articles/204791510 |
||
150 | * |
||
151 | * @param integer $id |
||
152 | * @param integer $guestSpaceId |
||
153 | * @param string $lang |
||
154 | * @return array |
||
155 | */ |
||
156 | public function getRecordAcl($id, $guestSpaceId = null, $lang = 'default') |
||
164 | |||
165 | /** |
||
166 | * Get field acl |
||
167 | * https://cybozudev.zendesk.com/hc/ja/articles/204791520 |
||
168 | * |
||
169 | * @param integer $id |
||
170 | * @param integer $guestSpaceId |
||
171 | * @param string $lang |
||
172 | * @return array |
||
173 | */ |
||
174 | public function getFieldAcl($id, $guestSpaceId = null, $lang = 'default') |
||
182 | |||
183 | /** |
||
184 | * Get app JavaScript and CSS customize |
||
185 | * https://cybozudev.zendesk.com/hc/ja/articles/204529824 |
||
186 | * |
||
187 | * @param integer $id |
||
188 | * @param integer $guestSpaceId |
||
189 | * @return array |
||
190 | */ |
||
191 | public function getCustomize($id, $guestSpaceId = null) |
||
199 | |||
200 | /** |
||
201 | * Get app status list |
||
202 | * https://cybozudev.zendesk.com/hc/ja/articles/216972946 |
||
203 | * |
||
204 | * @param integer $id |
||
205 | * @param string $lang |
||
206 | * @param integer $guestSpaceId |
||
207 | * @return array |
||
208 | */ |
||
209 | public function getStatus($id, $lang = 'ja', $guestSpaceId = null) |
||
217 | } |
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: