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 |
||
| 26 | class EntityQueryEntities extends FieldPluginBase implements ContainerFactoryPluginInterface { |
||
|
|
|||
| 27 | use DependencySerializationTrait; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * The entity buffer service. |
||
| 31 | * |
||
| 32 | * @var \Drupal\graphql\GraphQL\Buffers\EntityBuffer |
||
| 33 | */ |
||
| 34 | protected $entityBuffer; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * The entity type manager service. |
||
| 38 | * |
||
| 39 | * @var \Drupal\Core\Entity\EntityTypeManagerInterface |
||
| 40 | */ |
||
| 41 | protected $entityTypeManager; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | public function __construct( |
||
| 57 | |||
| 58 | /** |
||
| 59 | * {@inheritdoc} |
||
| 60 | */ |
||
| 61 | public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { |
||
| 70 | |||
| 71 | /** |
||
| 72 | * {@inheritdoc} |
||
| 73 | */ |
||
| 74 | public function resolveValues($value, array $args, ResolveInfo $info) { |
||
| 87 | |||
| 88 | protected function resolveFromEntityIds($type, $ids) { |
||
| 94 | |||
| 95 | protected function resolveFromRevisionIds($type, $ids) { |
||
| 103 | |||
| 104 | protected function resolveEntities(array $entities) { |
||
| 117 | |||
| 118 | } |
||
| 119 |