Completed
Pull Request — experimental/3.1 (#2518)
by Kiyotaka
98:08 queued 92:00
created

QueryExtensionScanner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 33
loc 33
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getAnnotationClass() 4 4 1
A createComponentDefinition() 4 4 1
A generateExtend() 11 11 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 Eccube\Di\Scanner;
25
26
27
use Eccube\Annotation\QueryExtension;
28
use Eccube\Di\ComponentDefinition;
29
30 View Code Duplication
class QueryExtensionScanner extends ComponentScanner
0 ignored issues
show
Duplication introduced by
This class 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...
introduced by
Missing class doc comment
Loading history...
31
{
32
    /**
33
     * QueryExtensionScanner constructor.
34
     * @param array|string[] $scanDirs
35
     */
36 1093
    public function __construct($scanDirs)
37
    {
38 1093
        parent::__construct($scanDirs);
39
    }
40
41 15
    public function getAnnotationClass()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
42
    {
43 15
        return QueryExtension::class;
44
    }
45
46 15
    public function createComponentDefinition($anno, $refClass)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
47
    {
48 15
        return new ComponentDefinition($refClass->getName(), $refClass);
49
    }
50
51 15
    public function generateExtend(\Twig_Environment $twig, array $components)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
52
    {
53 15
        return $twig->createTemplate(
54 15
'$app->extend("eccube.queries", function ($queries, $app) {
55
    {% for extension in extensions -%}
56
    $queries->addCustomizer($app["{{ extension.id }}"]);
57
    {% endfor %}
58
59
    return $queries;
60 15
});')->render(['extensions' => $components]);
61
    }
62
}