Completed
Pull Request — experimental/3.1 (#2518)
by Kiyotaka
76:23 queued 70:09
created

EntityEventScanner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 31
loc 31
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\EntityEvent;
28
use Eccube\Di\ComponentDefinition;
29
30 View Code Duplication
class EntityEventScanner 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 1073
    public function __construct($scanDirs)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
33
    {
34 1073
        parent::__construct($scanDirs);
35
    }
36
37 15
    public function getAnnotationClass()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
38
    {
39 15
        return EntityEvent::class;
40
    }
41
42 15
    public function createComponentDefinition($anno, $refClass)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
43
    {
44 15
        return new ComponentDefinition($refClass->getName(), $refClass);
45
    }
46
47 15
    public function generateExtend(\Twig_Environment $twig, array $components)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
48
    {
49 15
        return $twig->createTemplate(
50 15
'$app->extend("eccube.entity.event.dispatcher", function ($eventDispatcher, $app) {
51
    {% for event in events -%}
52
    $eventDispatcher->addEventListener($app["{{ event.id }}"]);
53
    {% endfor %}
54
55
    return $eventDispatcher;
56 15
});')->render(['events' => $components]);
57
    }
58
59
60
}