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 |
||
17 | abstract class AbstractProcessor implements AnnotationProcessorInterface |
||
18 | { |
||
19 | /** |
||
20 | * Pattern of "resource" parameter of link annotation |
||
21 | */ |
||
22 | const RESOURCE_PATTERN = '~^(?<repository>[a-z_][a-z0-9_]*)\.(?<link>[a-z_][a-z0-9_]*)$~i'; |
||
23 | |||
24 | /** |
||
25 | * Annotation classes ha been registered. |
||
26 | * |
||
27 | * @var bool |
||
28 | */ |
||
29 | static private $annotationsRegistered = false; |
||
30 | |||
31 | /** |
||
32 | * Doctrine annotation reader |
||
33 | * |
||
34 | * @var Reader |
||
35 | */ |
||
36 | protected $reader; |
||
37 | |||
38 | /** |
||
39 | * AnnotationDefinitionProvider constructor. |
||
40 | * |
||
41 | * @param Reader $reader |
||
42 | */ |
||
43 | 28 | public function __construct(Reader $reader) |
|
49 | |||
50 | /** |
||
51 | * Register annotation classes. |
||
52 | * Supports a medieval-aged way of "autoloading" for the Doctrine Annotation library. |
||
53 | */ |
||
54 | 28 | static protected function registerAnnotations() |
|
65 | |||
66 | /** |
||
67 | * Create link by link's annotation |
||
68 | * |
||
69 | * @param LinkAnnotation $annotation |
||
70 | * @return Link |
||
71 | */ |
||
72 | 6 | protected function createLink(LinkAnnotation $annotation): Link |
|
89 | |||
90 | /** |
||
91 | * Resolve getter of related object |
||
92 | * |
||
93 | * @param \ReflectionProperty $property |
||
94 | * @return string |
||
95 | */ |
||
96 | 22 | protected function resolveGetter(\ReflectionProperty $property) |
|
116 | |||
117 | /** |
||
118 | * Resolve getter of related object |
||
119 | * |
||
120 | * @param \ReflectionProperty $property |
||
121 | * @return string | null |
||
122 | */ |
||
123 | 18 | protected function resolveSetter(\ReflectionProperty $property) |
|
134 | } |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.