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 |
||
| 11 | class TicketMutation |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Maps the GraphQL input to a format that the model functions can use |
||
| 16 | * |
||
| 17 | * @param array $input Data coming from the GraphQL mutation query input |
||
| 18 | * @return array |
||
| 19 | */ |
||
| 20 | public static function prepareFields(array $input) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Sets the related tickets for the given datetime. |
||
| 48 | * |
||
| 49 | * @param EE_Ticket $entity The Ticket instance. |
||
| 50 | * @param array $datetimes Array of datetime IDs to relate. |
||
| 51 | */ |
||
| 52 | public static function setRelatedDatetimes($entity, array $datetimes) |
||
| 65 | } |
||
| 66 |