Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
49:41 queued 37:58
created

ProductClassEditPage   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 71
Duplicated Lines 11.27 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 8
loc 71
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 1

How to fix   Duplicated Code   

Duplicated Code

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
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2018 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
namespace Page\Admin;
25
26
27
class ProductClassEditPage extends AbstractAdminPageStyleGuide
28
{
29
    public static $登録完了メッセージ = ['css' => '#page_admin_product_product_class > div > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3'];
30
31
    public static $初期化ボタン = ['css' => '#page_admin_product_product_class > div > div.c-contentsArea > div.c-contentsArea__cols > div > div > div > div.card-header > div > div.col-4.text-right > button'];
32
33
    public static $規格一覧 = ['css' => '#page_admin_product_product_class > div > div.c-contentsArea > div.c-contentsArea__cols > div > div > form > div.card.rounded.border-0.mb-4 > div.card-body.p-0 > table'];
34
    /**
35
     * ProductReProductClassEditPagegisterPage constructor.
36
     */
37
    public function __construct(\AcceptanceTester $I)
38
    {
39
        parent::__construct($I);
40
    }
41
42
    public static function at($I)
43
    {
44
        $page = new ProductClassEditPage($I);
45
        $page->atPage('商品登録(規格設定)商品管理');
46
        return $page;
47
    }
48
49
    public function 規格設定()
50
    {
51
        $this->tester->click(['css' => 'div.c-contentsArea form button']);
52
        return $this;
53
    }
54
55
    public function 入力_規格1($value)
56
    {
57
        $this->tester->selectOption(['id' => 'product_class_matrix_class_name1'], $value);
58
        return $this;
59
    }
60
61
    public function 入力_在庫数無制限($rowNum)
62
    {
63
        $rowNum -= 1;
64
        $this->tester->checkOption(['id' => "product_class_matrix_product_classes_${rowNum}_stock_unlimited"]);
65
        return $this;
66
    }
67
68
    public function 入力_販売価格($rowNum, $value)
69
    {
70
        $rowNum -= 1;
71
        $this->tester->fillField(['id' => "product_class_matrix_product_classes_${rowNum}_price02"], $value);
72
        return $this;
73
74
    }
75
76
    public function 選択($rowNum)
77
    {
78
        $rowNum -= 1;
79
        $this->tester->checkOption(['id' => "product_class_matrix_product_classes_${rowNum}_checked"]);
80
        return $this;
81
    }
82
83
    public function 規格初期化()
84
    {
85
        $this->tester->click(self::$初期化ボタン);
86
        $this->tester->waitForElement(['css' => '#initializationConfirm > div > div > div.modal-footer > form > button']);
87
        $this->tester->wait(1);
88
        $this->tester->click(['css' => '#initializationConfirm > div > div > div.modal-footer > form > button']);
89
        return $this;
90
    }
91
92
    public function 登録()
93
    {
94
        $this->tester->click(['css' => 'button[name="product_class_matrix[save]"]']);
95
        return $this;
96
    }
97
}