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 |
||
| 5 | View Code Duplication | class InputObjectField |
|
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var string |
||
| 9 | */ |
||
| 10 | protected $name; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface|callable |
||
| 14 | */ |
||
| 15 | protected $type; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var mixed|null |
||
| 19 | */ |
||
| 20 | protected $defaultValue; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string|null |
||
| 24 | */ |
||
| 25 | protected $description; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Constructor. |
||
| 29 | * |
||
| 30 | * @param array $config |
||
| 31 | */ |
||
| 32 | 9 | public function __construct(array $config) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * @return \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface |
||
| 42 | */ |
||
| 43 | 9 | public function getType() |
|
| 51 | |||
| 52 | /** |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | 3 | public function getName() |
|
| 59 | |||
| 60 | /** |
||
| 61 | * @return string|null |
||
| 62 | */ |
||
| 63 | public function getDescription() |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return mixed|null |
||
| 70 | */ |
||
| 71 | 3 | public function getDefaultValue() |
|
| 75 | } |
||
| 76 |