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 |
||
18 | View Code Duplication | final class AdvancedErrorHandler implements ErrorHandlerInterface |
|
19 | { |
||
20 | /** |
||
21 | * @var ContentTypeResolverInterface |
||
22 | */ |
||
23 | private $contentTypeResolver; |
||
24 | |||
25 | /** |
||
26 | * @var ErrorResponseProviderInterface |
||
27 | */ |
||
28 | private $fallbackProvider; |
||
29 | |||
30 | /** |
||
31 | * @var ErrorResponseProviderInterface[] |
||
32 | */ |
||
33 | private $providers = []; |
||
34 | |||
35 | /** |
||
36 | * @var LoggerInterface |
||
37 | */ |
||
38 | private $logger; |
||
39 | |||
40 | /** |
||
41 | * @param ContentTypeResolverInterface $contentTypeResolver |
||
42 | * @param ErrorResponseProviderInterface $fallbackProvider |
||
43 | * @param array $providers |
||
44 | * @param LoggerInterface|null $logger |
||
45 | */ |
||
46 | 2 | public function __construct( |
|
60 | |||
61 | /** |
||
62 | * @param ErrorResponseProviderInterface $provider |
||
63 | */ |
||
64 | 2 | private function addProvider(ErrorResponseProviderInterface $provider) |
|
68 | |||
69 | /** |
||
70 | * @param Request $request |
||
71 | * @param Response $response |
||
72 | * @param \Exception $exception |
||
73 | * |
||
74 | * @return Response |
||
75 | * |
||
76 | * @throws \LogicException |
||
77 | */ |
||
78 | 2 | public function __invoke(Request $request, Response $response, \Exception $exception): Response |
|
90 | |||
91 | /** |
||
92 | * @param \Exception $exception |
||
93 | */ |
||
94 | 2 | private function logException(\Exception $exception) |
|
110 | } |
||
111 |
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.