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 | class ServerContext extends DefaultContext |
||
15 | { |
||
16 | /** |
||
17 | * @Given /^I am on the (teamspeak) instance creation page for "([^""]*)"$/ |
||
18 | * @When /^I go to the (teamspeak) instance creation page for "([^""]*)"$/ |
||
19 | */ |
||
20 | public function iAmOnTheVoipPage($type, $value) |
||
28 | |||
29 | /** |
||
30 | * @Given /^I should be on the (teamspeak) instance creation page for "([^""]*)"$/ |
||
31 | * @Given /^I should still be on the (teamspeak) instance creation page for "([^""]*)"$/ |
||
32 | */ |
||
33 | View Code Duplication | public function iShouldBeOnTheVoipPage($type, $value) |
|
42 | |||
43 | /** |
||
44 | * @Given /^I am on the page of (teamspeak) instance "([^""]*)"$/ |
||
45 | * @Given /^I go to the page of (teamspeak) instance "([^""]*)"$/ |
||
46 | */ |
||
47 | public function iAmOnTheInstancePageByName($type, $name) |
||
53 | |||
54 | /** |
||
55 | * @Given /^I am (building|viewing|editing) (teamspeak) instance "([^""]*)"$/ |
||
56 | */ |
||
57 | View Code Duplication | public function iAmDoingSomethingWithVoipResourceByName($action, $type, $name) |
|
64 | |||
65 | /** |
||
66 | * @Then /^I should be (building|viewing|editing) (teamspeak) instance "([^""]*)"$/ |
||
67 | * @Then /^I should still be (building|viewing|editing) (teamspeak) instance "([^""]*)"$/ |
||
68 | */ |
||
69 | View Code Duplication | public function iShouldBeDoingSomethingWithVoipResourceByName($action, $type, $name) |
|
77 | |||
78 | /** |
||
79 | * @Then /^I should be on the page of ([^""(w)]*) server "([^""]*)"$/ |
||
80 | * @Then /^I should still be on the page of ([^""(w)]*) server "([^""]*)"$/ |
||
81 | */ |
||
82 | public function iShouldBeOnTheServerPageByName($type, $name) |
||
86 | |||
87 | /** |
||
88 | * @Then /^I should be on the page of (teamspeak) instance "([^""]*)"$/ |
||
89 | * @Then /^I should still be on the page of (teamspeak) instance "([^""]*)"$/ |
||
90 | */ |
||
91 | View Code Duplication | public function iShouldBeOnTheInstancePageByName($type, $name) |
|
99 | |||
100 | /** |
||
101 | * @Given /^I am on the (teamspeak) "([^""]*)" instance index$/ |
||
102 | * @TODO: Refactorer comme iAmOnTheVoipPage() |
||
103 | */ |
||
104 | public function iAmOnTheInstanceIndex($type, $value) |
||
112 | |||
113 | /** |
||
114 | * @Then /^I should be on the (teamspeak) "([^"]*)" instance index$/ |
||
115 | */ |
||
116 | View Code Duplication | public function iShouldBeOnTheInstanceIndexPage($type, $value) |
|
125 | |||
126 | /** |
||
127 | * @Given /^I am (building|viewing|editing) (teamspeak) "([^""]*)"$/ |
||
128 | */ |
||
129 | View Code Duplication | public function iAmDoingSomethingWithVoipServer($action, $type, $value) |
|
140 | |||
141 | /** |
||
142 | * @Then /^I should be (building|viewing|editing|testing) (teamspeak) "([^""]*)"$/ |
||
143 | */ |
||
144 | View Code Duplication | public function iShouldBeDoingSomethingWithVoipServer($action, $type, $value) |
|
156 | |||
157 | /** |
||
158 | * @When /^I (?:click|press|follow) "([^"]*)" near "([^"]*)"$/ |
||
159 | */ |
||
160 | View Code Duplication | public function iClickNear($button, $value) |
|
173 | |||
174 | /** |
||
175 | * @Then /^I should be on the ftp page of ([^""]*) "([^""]*)"$/ |
||
176 | */ |
||
177 | View Code Duplication | public function iShouldBeOnTheFtpPage($type, $name) |
|
185 | |||
186 | /** |
||
187 | * @Then /^I should see (\d+) ([^" ]*) instances in (that|the) list$/ |
||
188 | */ |
||
189 | View Code Duplication | public function iShouldSeeThatMuchInstancesInTheList($amount, $type) |
|
197 | } |
||
198 |