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 |
||
| 7 | class PaymentEditPage extends AbstractAdminPageStyleGuide |
||
| 8 | { |
||
| 9 | public function __construct(\AcceptanceTester $I) |
||
| 10 | { |
||
| 11 | parent::__construct($I); |
||
| 12 | } |
||
| 13 | |||
| 14 | public static function at($I) |
||
| 15 | { |
||
| 16 | $page = new self($I); |
||
| 17 | return $page->atPage('支払方法登録・編集基本情報設定'); |
||
| 18 | } |
||
| 19 | |||
| 20 | public function 入力_支払方法($value) { |
||
| 21 | $this->tester->fillField(['id' => 'payment_register_method'], $value); |
||
| 22 | return $this; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function 入力_手数料($value) { |
||
| 26 | $this->tester->fillField(['id' => 'payment_register_charge'], $value); |
||
| 27 | return $this; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function 入力_利用条件下限($value) { |
||
| 31 | $this->tester->fillField(['id' => 'payment_register_rule_min'], $value); |
||
| 32 | return $this; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function 登録() |
||
| 36 | { |
||
| 37 | $this->tester->click('#form1 > .c-conversionArea > .c-conversionArea__container button.btn-ec-conversion'); |
||
| 38 | } |
||
| 39 | |||
| 40 | } |