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 |
||
12 | class PhpMatcher implements Context |
||
13 | { |
||
14 | use ApiTrait; |
||
15 | |||
16 | /** @var Factory */ |
||
17 | private $factory; |
||
18 | |||
19 | public function __construct(HttpHistory $history, Factory $factory = null) |
||
20 | { |
||
21 | $this->history = $history; |
||
22 | |||
23 | $this->factory = $factory ?: new SimpleFactory; |
||
24 | } |
||
25 | |||
26 | /** @Then the response content should match :pattern */ |
||
27 | View Code Duplication | public function response_content_should_match(string $pattern) |
|
44 | |||
45 | /** @Then the response content should not match :pattern */ |
||
46 | View Code Duplication | public function response_content_should_not_match(string $pattern) |
|
63 | |||
64 | /** @Then the response content should match: */ |
||
65 | View Code Duplication | public function response_content_should_match_PyString(PyStringNode $pattern) |
|
76 | |||
77 | /** @Then the response content should match: */ |
||
78 | View Code Duplication | public function response_content_should_not_match_PyString(PyStringNode $pattern) |
|
89 | } |
||
90 |