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 |
||
31 | class RouteEntity extends FieldPluginBase implements ContainerFactoryPluginInterface { |
||
|
|||
32 | use DependencySerializationTrait; |
||
33 | |||
34 | /** |
||
35 | * The entity type manager. |
||
36 | * |
||
37 | * @var \Drupal\Core\Entity\EntityTypeManagerInterface |
||
38 | */ |
||
39 | protected $entityTypeManager; |
||
40 | |||
41 | /** |
||
42 | * The language manager. |
||
43 | * |
||
44 | * @var \Drupal\Core\Language\LanguageManagerInterface |
||
45 | */ |
||
46 | protected $languageManager; |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function __construct( |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function resolveValues($value, array $args, ResolveInfo $info) { |
||
101 | |||
102 | } |
||
103 |