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 |
||
9 | View Code Duplication | class RunnerOptions |
|
10 | { |
||
11 | /** |
||
12 | * @var UrlCollection |
||
13 | */ |
||
14 | private $urls; |
||
15 | |||
16 | /** |
||
17 | * @var RequestTimeout |
||
18 | */ |
||
19 | private $requestTimeout; |
||
20 | |||
21 | /** |
||
22 | * @var FollowRedirect |
||
23 | */ |
||
24 | private $followRedirect; |
||
25 | |||
26 | /** |
||
27 | * @var BasicAuth|null |
||
28 | */ |
||
29 | private $basicAuth; |
||
30 | |||
31 | /** |
||
32 | * @param UrlCollection $urls |
||
33 | * @param RequestTimeout $requestTimeout |
||
34 | * @param FollowRedirect $followRedirect |
||
35 | * @param BasicAuth|null $basicAuth |
||
36 | */ |
||
37 | public function __construct( |
||
48 | |||
49 | /** |
||
50 | * @return UrlCollection |
||
51 | */ |
||
52 | public function getUrls() |
||
56 | |||
57 | /** |
||
58 | * @return RequestTimeout |
||
59 | */ |
||
60 | public function getRequestTimeout() |
||
64 | |||
65 | /** |
||
66 | * @return FollowRedirect |
||
67 | */ |
||
68 | public function getFollowRedirect() |
||
72 | |||
73 | /** |
||
74 | * @return BasicAuth|null |
||
75 | */ |
||
76 | public function getBasicAuth() |
||
80 | } |
||
81 |