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 |
||
23 | View Code Duplication | class ExternalRequest extends FieldPluginBase implements ContainerFactoryPluginInterface { |
|
24 | use DependencySerializationTrait; |
||
25 | |||
26 | /** |
||
27 | * @var \GuzzleHttp\ClientInterface |
||
28 | */ |
||
29 | protected $httpClient; |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public static function create( |
||
47 | |||
48 | /** |
||
49 | * ExternalRequest constructor. |
||
50 | * |
||
51 | * @param array $configuration |
||
52 | * The plugin configuration array. |
||
53 | * @param string $pluginId |
||
54 | * The plugin id. |
||
55 | * @param mixed $pluginDefinition |
||
56 | * The plugin definition array. |
||
57 | * @param \GuzzleHttp\ClientInterface $httpClient |
||
58 | * The http client service. |
||
59 | */ |
||
60 | public function __construct( |
||
69 | |||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | protected function resolveValues($value, array $args, ResolveInfo $info) { |
||
79 | |||
80 | } |
||
81 |