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 DatetimeMutation |
||
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) |
||
53 | |||
54 | /** |
||
55 | * Sets the related tickets for the given datetime. |
||
56 | * |
||
57 | * @param EE_Datetime $entity The datetime instance. |
||
58 | * @param array $tickets Array of ticket IDs to relate. |
||
59 | */ |
||
60 | public static function setRelatedTickets($entity, array $tickets) |
||
73 | } |
||
74 |