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 | View Code Duplication | final class SimpleErrorHandler implements ErrorHandlerInterface |
|
18 | { |
||
19 | /** |
||
20 | * @var ErrorResponseProviderInterface |
||
21 | */ |
||
22 | private $provider; |
||
23 | |||
24 | /** |
||
25 | * @var LoggerInterface |
||
26 | */ |
||
27 | private $logger; |
||
28 | |||
29 | /** |
||
30 | * @param ErrorResponseProviderInterface $provider |
||
31 | */ |
||
32 | 2 | public function __construct(ErrorResponseProviderInterface $provider, LoggerInterface $logger = null) |
|
37 | |||
38 | /** |
||
39 | * @param Request $request |
||
40 | * @param Response $response |
||
41 | * @param \Exception $exception |
||
42 | * |
||
43 | * @return Response |
||
44 | */ |
||
45 | 2 | public function __invoke(Request $request, Response $response, \Exception $exception): Response |
|
51 | |||
52 | /** |
||
53 | * @param \Exception $exception |
||
54 | */ |
||
55 | 2 | private function logException(\Exception $exception) |
|
71 | } |
||
72 |
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.