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 FieldArgument | |
| 6 | { | ||
| 7 | /** | ||
| 8 | * @var string | ||
| 9 | */ | ||
| 10 | protected $name; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * @var string|null | ||
| 14 | */ | ||
| 15 | protected $description; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @var \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface|callable | ||
| 19 | */ | ||
| 20 | protected $type; | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @var mixed | ||
| 24 | */ | ||
| 25 | protected $defaultValue; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Constructor. | ||
| 29 | * | ||
| 30 | * @param array $config | ||
| 31 | */ | ||
| 32 | 159 | public function __construct(array $config) | |
| 42 | |||
| 43 | /** | ||
| 44 | * @return string | ||
| 45 | */ | ||
| 46 | 165 | public function getName() | |
| 50 | |||
| 51 | /** | ||
| 52 | * @return string|null | ||
| 53 | */ | ||
| 54 | 3 | public function getDescription() | |
| 58 | |||
| 59 | /** | ||
| 60 | * @return \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface | ||
| 61 | */ | ||
| 62 | 207 | public function getType() | |
| 70 | |||
| 71 | /** | ||
| 72 | * @return mixed|null | ||
| 73 | */ | ||
| 74 | 6 | public function getDefaultValue() | |
| 78 | } | ||
| 79 |