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 |
||
13 | class DatetimeMutation |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * Maps the GraphQL input to a format that the model functions can use |
||
18 | * |
||
19 | * @param array $input Data coming from the GraphQL mutation query input |
||
20 | * @return array |
||
21 | */ |
||
22 | public static function prepareFields(array $input) |
||
58 | |||
59 | /** |
||
60 | * Sets the related tickets for the given datetime. |
||
61 | * |
||
62 | * @param EE_Datetime $entity The datetime instance. |
||
63 | * @param array $tickets Array of ticket IDs to relate. |
||
64 | */ |
||
65 | View Code Duplication | public static function setRelatedTickets($entity, array $tickets) |
|
81 | } |
||
82 |