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 |
||
28 | View Code Duplication | class EntityById extends FieldPluginBase implements ContainerFactoryPluginInterface { |
|
29 | |||
30 | use DependencySerializationTrait; |
||
31 | |||
32 | /** |
||
33 | * @var \Drupal\graphql\GraphQL\Batching\Buffers\EntityBuffer |
||
34 | */ |
||
35 | protected $entityBuffer; |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | public function __construct(array $configuration, $pluginId, $pluginDefinition, EntityBuffer $entityBuffer) { |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { |
||
56 | |||
57 | protected function resolveValues($value, array $args, ResolveInfo $info) { |
||
63 | |||
64 | } |
||
65 |