Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
17 | class Customers extends Client |
||
18 | { |
||
19 | /** |
||
20 | * Retrieve customers |
||
21 | * |
||
22 | * Get a list of customers. |
||
23 | * |
||
24 | * @param string|null $searchText |
||
25 | * @param string|null $searchField |
||
26 | * @param string|null $createdSince date-time |
||
27 | * @param bool|null $currentMembers |
||
28 | * @param bool|null $currentNonMembers |
||
29 | * @param int $itemsPerPage maximum: 100 |
||
30 | * @param string|null $pageNavigationToken |
||
31 | * @param int $pageNumber |
||
32 | * |
||
33 | * @return \Bookeo\Interfaces\QueryInterface |
||
34 | */ |
||
35 | public function all( |
||
85 | |||
86 | /** |
||
87 | * Create a new customer. |
||
88 | * |
||
89 | * Please note there is a limit to the number of customers that can be imported in Bookeo. Bookeo is primarily a booking system, not a CRM. |
||
90 | * |
||
91 | * @param Customer $customer |
||
92 | * |
||
93 | * @return \Bookeo\Interfaces\QueryInterface |
||
94 | */ |
||
95 | public function create(Customer $customer): QueryInterface |
||
105 | |||
106 | /** |
||
107 | * Retrieve a customer |
||
108 | * |
||
109 | * Retrieve a customer by its id |
||
110 | * |
||
111 | * @param string $customer_id |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function __invoke(string $customer_id) |
||
126 | |||
127 | /** |
||
128 | * Update an existing customer |
||
129 | * |
||
130 | * @param Customer $customer |
||
131 | * |
||
132 | * @return \Bookeo\Interfaces\QueryInterface |
||
133 | */ |
||
134 | View Code Duplication | public function update(Customer $customer): QueryInterface |
|
143 | |||
144 | /** |
||
145 | * Delete a customer |
||
146 | * |
||
147 | * Please note it is not possible to delete customers that have bookings in the future, and that are not cancelled. |
||
148 | * If your application needs to delete a customer with future bookings, make sure to cancel all future bookings for that customer first. |
||
149 | * |
||
150 | * @return \Bookeo\Interfaces\QueryInterface |
||
151 | */ |
||
152 | public function delete(): QueryInterface |
||
160 | |||
161 | /** |
||
162 | * The customer's email address is the "username" used by Bookeo to authenticate customers. |
||
163 | * So to authenticate a customer your application would typically use GET /customers to search for customers with a given email address, and then GET |
||
164 | * /customers/{id}/authenticate to authenticate. Remember that there may be duplicate customer records with the same email address, ex. due to duplicate importing or manual |
||
165 | * record creation. |
||
166 | * |
||
167 | * @param string $password |
||
168 | * |
||
169 | * @return \Bookeo\Interfaces\QueryInterface |
||
170 | */ |
||
171 | View Code Duplication | public function authenticate(string $password): QueryInterface |
|
181 | |||
182 | /** |
||
183 | * @param string|null $beginDate if specified, only bookings on or after this date will be included |
||
184 | * @param string|null $endDate if specified, only bookings on or before this date will be included |
||
185 | * @param bool $expandParticipants if true, full details of the participants are included (provided the application has read permission over the participant) |
||
186 | * @param int $itemsPerPage maximum: 100 |
||
187 | * @param string|null $pageNavigationToken |
||
188 | * @param int $pageNumber |
||
189 | * |
||
190 | * @return \Bookeo\Interfaces\QueryInterface |
||
191 | */ |
||
192 | public function bookings( |
||
232 | |||
233 | /** |
||
234 | * Get the people linked to a customer |
||
235 | * |
||
236 | * @param int $itemsPerPage maximum: 100 |
||
237 | * @param string|null $pageNavigationToken |
||
238 | * @param int $pageNumber |
||
239 | * |
||
240 | * @return \Bookeo\Interfaces\QueryInterface |
||
241 | */ |
||
242 | View Code Duplication | public function linkedpeople( |
|
267 | } |
||
268 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: