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 |
||
14 | class ArticleTwigExtension extends Twig_Extension |
||
|
|||
15 | { |
||
16 | /** |
||
17 | * @var EntityManagerInterface |
||
18 | */ |
||
19 | private $em; |
||
20 | |||
21 | /** |
||
22 | * @var RouterInterface |
||
23 | */ |
||
24 | private $router; |
||
25 | |||
26 | /** |
||
27 | * ArticleTwigExtension constructor. |
||
28 | * |
||
29 | * @param EntityManagerInterface $em |
||
30 | * @param RouterInterface $router |
||
31 | */ |
||
32 | public function __construct(EntityManagerInterface $em, RouterInterface $router) |
||
41 | |||
42 | /** |
||
43 | * Returns a list of functions to add to the existing list. |
||
44 | * |
||
45 | * @return array An array of functions |
||
46 | */ |
||
47 | public function getFunctions() |
||
64 | |||
65 | /** |
||
66 | * Get tags array for view. |
||
67 | * |
||
68 | * @param Request $request |
||
69 | * @param string $className |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | View Code Duplication | public function getTags(Request $request, $className) |
|
88 | |||
89 | /** |
||
90 | * Get categories array for view. |
||
91 | * |
||
92 | * @param Request $request |
||
93 | * @param string $className |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | View Code Duplication | public function getCategories(Request $request, $className) |
|
112 | |||
113 | /** |
||
114 | * @param string $slug |
||
115 | * @param string $tag |
||
116 | * @param string $locale |
||
117 | * @param array $parameters |
||
118 | * @param int $referenceType |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getArticleTagRouterPath($slug, $tag, $locale, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) |
||
128 | |||
129 | /** |
||
130 | * @param string $slug |
||
131 | * @param string $category |
||
132 | * @param string $locale |
||
133 | * @param array $parameters |
||
134 | * @param int $referenceType |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getArticleCategoryRouterPath($slug, $category, $locale, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) |
||
144 | |||
145 | /** |
||
146 | * @return string |
||
147 | */ |
||
148 | public function getName() |
||
152 | |||
153 | /** |
||
154 | * @param string $routeName |
||
155 | * @param string $type |
||
156 | * @param string $slug |
||
157 | * @param string $tagOrCategory |
||
158 | * @param string $locale |
||
159 | * @param array $parameters |
||
160 | * @param int $referenceType |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | protected function getArticleRouterPath($routeName, $type, $slug, $tagOrCategory, $locale, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) |
||
181 | |||
182 | /** |
||
183 | * @param string $type |
||
184 | * @param string $locale |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | protected function articleRouteExists($type, $locale) |
||
198 | } |
||
199 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.