Failed Conditions
Push — modify-scrutinizeryml ( 361e25...08b4c1 )
by Kentaro
63:54 queued 57:30
created

LayoutEditPage   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 94
Duplicated Lines 14.89 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 14
loc 94
rs 10
c 0
b 0
f 0
wmc 12
lcom 1
cbo 1

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A at() 0 5 1
A 登録() 0 6 1
A ブロックを移動() 0 6 1
A コンテキストメニューを開く() 0 5 1
A コンテキストメニューで上に移動() 7 7 1
A コンテキストメニューで下に移動() 7 7 1
A コンテキストメニューでセクションに移動() 0 13 1
A コンテキストメニューでコードプレビュー() 0 12 2
A プレビュー() 0 5 1
A 検索ブロック名() 0 5 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
4
namespace Page\Admin;
5
6
7
class LayoutEditPage extends AbstractAdminPageStyleGuide
8
{
9
    public static $未使用ブロックアイテム = ['css' => '#unused-block div.sort'];
10
    public static $登録完了メッセージ = ['xpath' => "//div[@class='alert alert-success alert-dismissible fade show m-3']"];
11
12
    /**
13
     * LayoutEditPage constructor.
14
     */
15
    public function __construct(\AcceptanceTester $I)
16
    {
17
        parent::__construct($I);
18
    }
19
20
    public static function at($I)
21
    {
22
        $page = new self($I);
23
        return $page->atPage('レイアウト管理コンテンツ管理');
24
    }
25
26
    public function 登録()
27
    {
28
        $this->tester->waitForElementVisible('#form1 > div > div.c-conversionArea > div > div > div:nth-child(2) > div > div > button');
29
        $this->tester->click('#form1 > div > div.c-conversionArea > div > div > div:nth-child(2) > div > div > button');
30
        return $this;
31
    }
32
33
    public function ブロックを移動($blockName, $dest, $timeout = 10)
34
    {
35
        $this->tester->waitForElementVisible(['xpath' => "//div[contains(@id, 'detail_box__layout_item')][div[div[1][a[text()='${blockName}']]]]"], $timeout);
36
        $this->tester->dragAndDrop(['xpath' => "//div[contains(@id, 'detail_box__layout_item')][div[div[1][a[text()='${blockName}']]]]"], $dest);
37
        return $this;
38
    }
39
40
    public function コンテキストメニューを開く($blockName)
41
    {
42
        $this->tester->click(['xpath' => "//div[contains(@id, 'detail_box__layout_item')][div[div[1][a[text()='${blockName}']]]]/div/div[2]"]);
43
        return $this;
44
    }
45
46 View Code Duplication
    public function コンテキストメニューで上に移動($blockName)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
    {
48
        $this->コンテキストメニューを開く($blockName);
49
        $this->tester->waitForElementVisible(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[1]"]);
50
        $this->tester->click(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[1]"]);
51
        return $this;
52
    }
53
54 View Code Duplication
    public function コンテキストメニューで下に移動($blockName)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
    {
56
        $this->コンテキストメニューを開く($blockName);
57
        $this->tester->waitForElementVisible(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[2]"]);
58
        $this->tester->click(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[2]"]);
59
        return $this;
60
    }
61
62
    public function コンテキストメニューでセクションに移動($blockName)
63
    {
64
        $this->コンテキストメニューを開く($blockName);
65
        $this->tester->waitForElementVisible(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[3]"]);
66
        $this->tester->wait(1);
67
        $this->tester->click(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[3]"]);
68
        $this->tester->waitForElementVisible(['id' => "move-to-section"]);
69
        $this->tester->wait(1);
70
        $this->tester->click(['id' => "move-to-section"]);
71
        $this->tester->waitForElementNotVisible(['id' => "move-to-section"]);
72
        $this->tester->wait(1);
73
        return $this;
74
    }
75
76
    public function コンテキストメニューでコードプレビュー($blockName, $element = null, $timeout = 10)
77
    {
78
        $this->コンテキストメニューを開く($blockName);
79
        $this->tester->waitForElementVisible(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[4]"]);
80
        $this->tester->click(['xpath' => "//div[contains(@id, 'popover')]/div[2]/div/a[4]"]);
81
        $this->tester->waitForElementVisible(['id' => "codePreview"]);
82
        if ($element) {
83
            $this->tester->waitForElementVisible($element, $timeout);
84
        }
85
        $this->tester->click(['xpath' => "//*[@id='codePreview']/div/div/div[3]/button[1]"]);
86
        return $this;
87
    }
88
89
    public function プレビュー()
90
    {
91
        $this->tester->click("#preview_box__preview_button > button");
92
        return $this;
93
    }
94
95
    public function 検索ブロック名($value)
96
    {
97
        $this->tester->fillField(['css' => '#unused-block div.first input'], $value);
98
        return $this;
99
    }
100
}
101