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 |
||
40 | class EntityQuery extends FieldPluginBase implements ContainerFactoryPluginInterface { |
||
|
|||
41 | use DependencySerializationTrait; |
||
42 | |||
43 | /** |
||
44 | * The entity type manager. |
||
45 | * |
||
46 | * @var \Drupal\Core\Entity\EntityTypeManagerInterface |
||
47 | */ |
||
48 | protected $entityTypeManager; |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function __construct(array $configuration, $pluginId, $pluginDefinition, EntityTypeManagerInterface $entityTypeManager) { |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | protected function getCacheDependencies($result, $value, array $args) { |
||
83 | |||
84 | /** |
||
85 | * Retrieves the schema builder from the resolve info. |
||
86 | * |
||
87 | * @param \Youshido\GraphQL\Execution\ResolveInfo $info |
||
88 | * The resolve info object. |
||
89 | * |
||
90 | * @return \Drupal\graphql\Plugin\GraphQL\PluggableSchemaBuilderInterface|null |
||
91 | * The corresponding plugin instance for this edge. |
||
92 | */ |
||
93 | View Code Duplication | protected function getSchemaBuilder(ResolveInfo $info) { |
|
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | public function resolveValues($value, array $args, ResolveInfo $info) { |
||
134 | |||
135 | } |
||
136 |