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 CustomerAgreementSettingPage extends AbstractAdminPage |
||
| 8 | { |
||
| 9 | public static $登録完了メッセージ = '#main .container-fluid div:nth-child(1) .alert-success'; |
||
| 10 | |||
| 11 | public function __construct(\AcceptanceTester $I) |
||
| 12 | { |
||
| 13 | parent::__construct($I); |
||
| 14 | } |
||
| 15 | |||
| 16 | public static function go($I) |
||
| 17 | { |
||
| 18 | $page = new self($I); |
||
| 19 | return $page->goPage('/setting/shop/customer_agreement', 'ショップ設定利用規約管理'); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function 入力_会員規約($value) |
||
| 23 | { |
||
| 24 | $this->tester->fillField(['id' => 'customer_agreement_customer_agreement'], $value); |
||
| 25 | return $this; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function 登録() |
||
| 29 | { |
||
| 30 | $this->tester->click('#form1 #aside_column button'); |
||
| 31 | } |
||
| 32 | } |