| Conditions | 11 |
| Paths | > 20000 |
| Total Lines | 99 |
| Code Lines | 55 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 44 | public function run($rejected = false) |
||
| 45 | { |
||
| 46 | $this->validateStep(self::STEP); |
||
| 47 | |||
| 48 | /* |
||
| 49 | * Field DNI: |
||
| 50 | */ |
||
| 51 | try { |
||
| 52 | $name = $this->webDriver->findElement(WebDriverBy::name('dni')); |
||
| 53 | $name->clear()->sendKeys($this->getDNI()); |
||
| 54 | } catch (\Exception $exception) { |
||
| 55 | unset($exception); |
||
| 56 | } |
||
| 57 | /* |
||
| 58 | * Field BirthDate: |
||
| 59 | */ |
||
| 60 | try { |
||
| 61 | $dob = $this->webDriver->findElement(WebDriverBy::name('dob')); |
||
| 62 | $dob->clear()->sendKeys('12/12/1979'); |
||
| 63 | } catch (\Exception $exception) { |
||
| 64 | unset($exception); |
||
| 65 | } |
||
| 66 | /* |
||
| 67 | * Field address: |
||
| 68 | */ |
||
| 69 | try { |
||
| 70 | $name = $this->webDriver->findElement(WebDriverBy::name('address')); |
||
| 71 | $name->clear()->sendKeys($this->faker->address. ' ' . $this->faker->city); |
||
| 72 | } catch (\Exception $exception) { |
||
| 73 | unset($exception); |
||
| 74 | } |
||
| 75 | /* |
||
| 76 | * Field city: |
||
| 77 | */ |
||
| 78 | try { |
||
| 79 | $name = $this->webDriver->findElement(WebDriverBy::name('city')); |
||
| 80 | $name->clear()->sendKeys($this->faker->city); |
||
| 81 | } catch (\Exception $exception) { |
||
| 82 | unset($exception); |
||
| 83 | } |
||
| 84 | /* |
||
| 85 | * Field zipcode: |
||
| 86 | */ |
||
| 87 | try { |
||
| 88 | $name = $this->webDriver->findElement(WebDriverBy::name('zipcode')); |
||
| 89 | $name->clear()->sendKeys('28045'); |
||
| 90 | } catch (\Exception $exception) { |
||
| 91 | unset($exception); |
||
| 92 | } |
||
| 93 | /* |
||
| 94 | * Field Phone: |
||
| 95 | */ |
||
| 96 | try { |
||
| 97 | $name = $this->webDriver->findElement(WebDriverBy::name('mobilePhone')); |
||
| 98 | $name->clear()->sendKeys('6' . $this->faker->randomNumber(8)); |
||
| 99 | } catch (\Exception $exception) { |
||
| 100 | unset($exception); |
||
| 101 | } |
||
| 102 | /* |
||
| 103 | * Field Full Name: |
||
| 104 | */ |
||
| 105 | try { |
||
| 106 | $name = $this->webDriver->findElement(WebDriverBy::name('name')); |
||
| 107 | $name->clear()->sendKeys( |
||
| 108 | $this->faker->firstName . ' ' . $this->faker->lastName |
||
| 109 | ); |
||
| 110 | } catch (\Exception $exception) { |
||
| 111 | unset($exception); |
||
| 112 | } |
||
| 113 | |||
| 114 | /* |
||
| 115 | * Field password: |
||
| 116 | */ |
||
| 117 | try { |
||
| 118 | $name = $this->webDriver->findElement(WebDriverBy::name('password')); |
||
| 119 | if (null === SeleniumHelper::$mobilePhone) { |
||
| 120 | throw new \Exception('Please provide mobile phone for returning customer'); |
||
| 121 | } else { |
||
| 122 | $name->clear()->sendKeys(substr(SeleniumHelper::$mobilePhone, -4)); |
||
| 123 | } |
||
| 124 | } catch (\Exception $exception) { |
||
| 125 | unset($exception); |
||
| 126 | } |
||
| 127 | |||
| 128 | /* |
||
| 129 | * Click form continue |
||
| 130 | */ |
||
| 131 | $element = WebDriverBy::name("continue_button"); |
||
| 132 | try { |
||
| 133 | $condition = WebDriverExpectedCondition::elementToBeClickable($element); |
||
| 134 | $this->webDriver->wait(90, 1500)->until($condition); |
||
| 135 | $formContinue = $this->webDriver->findElement($element); |
||
| 136 | $formContinue->click(); |
||
| 137 | } catch (\Exception $exception) { |
||
| 138 | sleep(10); |
||
| 139 | unset($exception); |
||
| 140 | } |
||
| 141 | |||
| 142 | return true; |
||
| 143 | } |
||
| 145 |