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 | View Code Duplication | class Translate extends FieldPluginBase implements ContainerFactoryPluginInterface { |
|
27 | use DependencySerializationTrait; |
||
28 | |||
29 | /** |
||
30 | * The language manager service. |
||
31 | * |
||
32 | * @var \Drupal\Core\Language\LanguageManagerInterface |
||
33 | */ |
||
34 | protected $languageManager; |
||
35 | |||
36 | /** |
||
37 | * Alias constructor. |
||
38 | * |
||
39 | * @param array $configuration |
||
40 | * The plugin configuration array. |
||
41 | * @param string $pluginId |
||
42 | * The plugin id. |
||
43 | * @param mixed $pluginDefinition |
||
44 | * The plugin definition. |
||
45 | * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager |
||
46 | * The language manager service. |
||
47 | */ |
||
48 | public function __construct( |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function resolveValues($value, array $args, ResolveInfo $info) { |
||
79 | |||
80 | } |
||
81 |