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 |
||
| 27 | class ShippingEditPage extends AbstractFrontPage |
||
| 28 | { |
||
| 29 | public function __construct(\AcceptanceTester $I) |
||
| 30 | { |
||
| 31 | parent::__construct($I); |
||
| 32 | } |
||
| 33 | |||
| 34 | public static function at($I) |
||
| 35 | { |
||
| 36 | $page = new self($I); |
||
| 37 | $page->tester->see('お届け先の変更', 'div.ec-pageHeader h1'); |
||
| 38 | return $page; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function 入力_姓($value) |
||
| 42 | { |
||
| 43 | $this->tester->fillField(['id' => 'shopping_shipping_name_name01'], $value); |
||
| 44 | return $this; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function 登録する() |
||
| 48 | { |
||
| 49 | $this->tester->click('div.ec-RegisterRole__actions button.ec-blockBtn--action'); |
||
| 50 | return $this; |
||
| 51 | } |
||
| 52 | } |