Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
121:51 queued 107:46
created

TopPage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 23.4 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 11
loc 47
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
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-2017 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\Front;
25
26
27
class TopPage extends AbstractFrontPage
28
{
29
30
    public static $検索_カテゴリ選択 = ['id' => 'category_id'];
31
    public static $検索_キーワード = ['id' => 'name'];
32
33
34
    public static function go(\AcceptanceTester $I)
35
    {
36
        $page = new self($I);
37
        return $page->goPage('');
38
    }
39
40
    public function 新着情報選択($rowNum)
41
    {
42
        $this->tester->click(['css' => "div.ec-news .ec-newsline:nth-child($rowNum) a"]);
43
        return $this;
44
    }
45
46
    public function 新着情報詳細($rowNum)
47
    {
48
        return $this->tester->grabTextFrom(['css' => "div.ec-news .ec-newsline:nth-child($rowNum) .ec-newsline__description"]);
49
    }
50
51
    public function 新着情報リンククリック($rowNum)
52
    {
53
        $this->tester->click(['css' => "div.ec-news .ec-newsline:nth-child($rowNum) .ec-newsline__description a"]);
54
    }
55
56
    public function カテゴリ選択($categories)
57
    {
58
        $xpath = "//*[@class='ec-layoutRole__header']/";
59
        foreach ($categories as $i=>$category) {
60
            $xpath .= "/ul/li/a[contains(text(), '$category')]/parent::node()";
61
            $this->tester->waitForElement(['xpath' => $xpath]);
62
            $this->tester->moveMouseOver(['xpath' => $xpath]);
63
        }
64
        $this->tester->click(['xpath' => $xpath]);
65
        return $this;
66
    }
67
68
    public function 検索()
69
    {
70
        $this->tester->click('button.ec-headerSearch__keywordBtn');
71
        return $this;
72
    }
73
}