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 |
||
38 | class Pointcut |
||
39 | { |
||
40 | /** |
||
41 | * Name of the aspect the pointcut is defined in |
||
42 | * |
||
43 | * @var string $aspectName |
||
44 | */ |
||
45 | protected $aspectName; |
||
46 | |||
47 | /** |
||
48 | * Name of function representing the pointcut within code |
||
49 | * |
||
50 | * @var string $name |
||
51 | */ |
||
52 | protected $name; |
||
53 | |||
54 | /** |
||
55 | * Expression defining the target of advices referencing this pointcut |
||
56 | * |
||
57 | * @var \AppserverIo\Doppelgaenger\Entities\PointcutExpression $pointcutExpression |
||
58 | */ |
||
59 | protected $pointcutExpression; |
||
60 | |||
61 | /** |
||
62 | * Getter for the $aspectName property |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | public function getAspectName() |
||
70 | |||
71 | /** |
||
72 | * Getter for the $name property |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function getName() |
||
80 | |||
81 | /** |
||
82 | * Getter for the $pointcutExpression property |
||
83 | * |
||
84 | * @return \AppserverIo\Doppelgaenger\Entities\PointcutExpression |
||
85 | */ |
||
86 | public function getPointcutExpression() |
||
90 | |||
91 | /** |
||
92 | * Will return the qualified name of an pointcut. |
||
93 | * Will have the form or <CONTAINING ASPECT>-><POINTCUT NAME> |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | View Code Duplication | public function getQualifiedName() |
|
106 | |||
107 | /** |
||
108 | * Setter for the $aspectName property |
||
109 | * |
||
110 | * @param string $aspectName Name of the aspect the pointcut is defined in |
||
111 | * |
||
112 | * @return null |
||
113 | */ |
||
114 | public function setAspectName($aspectName) |
||
118 | |||
119 | /** |
||
120 | * Setter for the $name property |
||
121 | * |
||
122 | * @param string $name Name of the pointcut |
||
123 | * |
||
124 | * @return null |
||
125 | */ |
||
126 | public function setName($name) |
||
130 | |||
131 | /** |
||
132 | * Setter for the $pointcutExpression property |
||
133 | * |
||
134 | * @param \AppserverIo\Doppelgaenger\Entities\PointcutExpression $pointcutExpression Expression defining the target |
||
135 | * |
||
136 | * @return null |
||
137 | */ |
||
138 | public function setPointcutExpression(PointcutExpression $pointcutExpression) |
||
142 | } |
||
143 |