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 | final class RequestMatcher implements RequestMatcherInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $path; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $host; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $methods = []; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $ips = []; |
||
|
|||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $attributes = []; |
||
40 | |||
41 | /** |
||
42 | * @var string[] |
||
43 | */ |
||
44 | private $schemes = []; |
||
45 | |||
46 | /** |
||
47 | * The regular expressions used for path or host must be specified without delimiter. |
||
48 | * You do not need to escape the forward slash / to match it. |
||
49 | * |
||
50 | * @param string|null $path Regular expression for the path |
||
51 | * @param string|null $host Regular expression for the hostname |
||
52 | * @param string|string[]|null $methods Method or list of methods to match |
||
53 | * @param string|string[]|null $schemes Scheme or list of schemes to match (e.g. http or https) |
||
54 | */ |
||
55 | public function __construct($path = null, $host = null, $methods = [], $schemes = []) |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | * |
||
66 | * @api |
||
67 | */ |
||
68 | public function matches(RequestInterface $request) |
||
88 | } |
||
89 |
This check marks private properties in classes that are never used. Those properties can be removed.