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 |
||
17 | class WebDriver extends RemoteWebDriver implements LoggerAware |
||
18 | { |
||
19 | const INSTRUCTION_MOUSE_MOVETO = 'mouseMoveTo'; |
||
20 | const INSTRUCTION_MOUSE_CLICK = 'mouseClick'; |
||
21 | |||
22 | const BY_XPATH = 'byXpath'; |
||
23 | const BY_ID = 'byId'; |
||
24 | const BY_CSS_SELECTOR = 'byCssSelector'; |
||
25 | |||
26 | /** |
||
27 | * @var \Magium\Util\Log\LoggerInterface |
||
28 | */ |
||
29 | |||
30 | protected $logger; |
||
31 | |||
32 | protected $browser; |
||
33 | protected $platform; |
||
34 | |||
35 | /** |
||
36 | * @return mixed |
||
37 | */ |
||
38 | public function getBrowser() |
||
42 | |||
43 | /** |
||
44 | * @return mixed |
||
45 | */ |
||
46 | public function getPlatform() |
||
50 | |||
51 | public function setCommandExecutor(WebDriverCommandExecutor $executor) |
||
60 | |||
61 | |||
62 | public function logFind($by, $selector) |
||
80 | |||
81 | public function logElement(WebDriverElement $element) |
||
99 | |||
100 | public function setRemoteExecuteMethod(LoggingRemoteExecuteMethod $method) |
||
104 | |||
105 | public function setLogger(LoggerInterface $logger) |
||
109 | |||
110 | /** |
||
111 | * @param WebDriverBy $by |
||
112 | * @return \Facebook\WebDriver\Remote\RemoteWebElement[] |
||
113 | */ |
||
114 | |||
115 | View Code Duplication | public function findElements(WebDriverBy $by) |
|
124 | |||
125 | /** |
||
126 | * @param WebDriverBy $by |
||
127 | * @return \Facebook\WebDriver\Remote\RemoteWebElement |
||
128 | */ |
||
129 | |||
130 | View Code Duplication | public function findElement(WebDriverBy $by) |
|
137 | |||
138 | public function elementExists($selector, $by = 'byId') |
||
147 | |||
148 | public function elementAttached(WebDriverElement $element) |
||
157 | |||
158 | public function elementDisplayed($selector, $by = 'byId') |
||
167 | |||
168 | /** |
||
169 | * |
||
170 | * @param string $xpath |
||
171 | * @return \Facebook\WebDriver\Remote\RemoteWebElement |
||
172 | */ |
||
173 | |||
174 | public function byXpath($xpath) |
||
178 | |||
179 | /** |
||
180 | * |
||
181 | * @param string $id |
||
182 | * @return \Facebook\WebDriver\Remote\RemoteWebElement |
||
183 | */ |
||
184 | |||
185 | public function byId($id) |
||
189 | |||
190 | /** |
||
191 | * |
||
192 | * @param string $selector |
||
193 | * @return \Facebook\WebDriver\Remote\RemoteWebElement |
||
194 | */ |
||
195 | |||
196 | public function byCssSelector($selector) |
||
200 | |||
201 | public function __destruct() |
||
211 | |||
212 | } |
||
213 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.