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 |
||
11 | class FeatureContext implements SnippetAcceptingContext |
||
|
|||
12 | { |
||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $phpBin; |
||
17 | /** |
||
18 | * @var Process |
||
19 | */ |
||
20 | private $process; |
||
21 | |||
22 | /** |
||
23 | * Prepares test folders in the temporary directory. |
||
24 | * |
||
25 | * @BeforeScenario |
||
26 | */ |
||
27 | public function prepareProcess() |
||
36 | |||
37 | /** |
||
38 | * Runs behat command with provided parameters |
||
39 | * |
||
40 | * @When /^I run "behat(?: ((?:\"|[^"])*))?"$/ |
||
41 | * |
||
42 | * @param string $argumentsString |
||
43 | */ |
||
44 | public function iRunBehat($argumentsString = '') |
||
61 | |||
62 | /** |
||
63 | * Checks whether previously runned command passes|failes with provided output. |
||
64 | * |
||
65 | * @Then /^it should (fail|pass) with:$/ |
||
66 | * |
||
67 | * @param string $success "fail" or "pass" |
||
68 | * @param PyStringNode $text PyString text instance |
||
69 | */ |
||
70 | public function itShouldPassWith($success, PyStringNode $text) |
||
75 | |||
76 | /** |
||
77 | * Checks whether last command output contains provided string. |
||
78 | * |
||
79 | * @Then the output should contain: |
||
80 | * |
||
81 | * @param PyStringNode $text PyString text instance |
||
82 | */ |
||
83 | public function theOutputShouldContain(PyStringNode $text) |
||
87 | |||
88 | private function getExpectedOutput(PyStringNode $expectedText) |
||
113 | |||
114 | /** |
||
115 | * Checks whether previously runned command failed|passed. |
||
116 | * |
||
117 | * @Then /^it should (fail|pass)$/ |
||
118 | * |
||
119 | * @param string $success "fail" or "pass" |
||
120 | */ |
||
121 | public function itShouldFail($success) |
||
137 | |||
138 | private function getExitCode() |
||
142 | |||
143 | private function getOutput() |
||
154 | } |
||
155 |
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.