Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 3 |
Ratio | 18.75 % |
Changes | 0 |
1 | <?php |
||
32 | public function extract() |
||
33 | { |
||
34 | View Code Duplication | if (!$this->webDriver->elementExists($this->theme->getAddToCartXpath(), 'byXpath')) { |
|
|
|||
35 | throw new NoSuchElementException('Could not find the simple add to cart element with the Xpath: ' . $this->theme->getAddToCartXpath()); |
||
36 | }; |
||
37 | |||
38 | $elements = $this->webDriver->findElements(WebDriverBy::xpath($this->theme->getAddToCartXpath())); |
||
39 | foreach ($elements as $element) { |
||
40 | if ($element->isDisplayed()) { |
||
41 | $this->element = $element; |
||
42 | return; |
||
43 | } |
||
44 | } |
||
45 | |||
46 | |||
47 | } |
||
48 | |||
49 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.