Advice   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 133
Duplicated Lines 6.77 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAspectName() 0 4 1
A getCodeHook() 0 4 1
A getName() 0 4 1
A getPointcuts() 0 4 1
A getQualifiedName() 9 9 2
A setAspectName() 0 4 1
A setCodeHook() 0 4 1
A setName() 0 4 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
 * \AppserverIo\Doppelgaenger\Entities\Definitions\Advice
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Bernhard Wick <[email protected]>
15
 * @copyright 2015 TechDivision GmbH - <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/doppelgaenger
18
 * @link      http://www.appserver.io/
19
 */
20
21
namespace AppserverIo\Doppelgaenger\Entities\Definitions;
22
23
use AppserverIo\Doppelgaenger\Entities\Lists\TypedList;
24
25
/**
26
 * Basic entity class which holds an advice representation
27
 *
28
 * @author    Bernhard Wick <[email protected]>
29
 * @copyright 2015 TechDivision GmbH - <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/appserver-io/doppelgaenger
32
 * @link      http://www.appserver.io/
33
 *
34
 * @property string                                              $aspectName Name of the aspect the advice is defined in
35
 * @property string                                              $codeHook   The code hook this advice is designed for
36
 * @property string                                              $name       Name of the advice itself
37
 * @property \AppserverIo\Doppelgaenger\Entities\Lists\TypedList $pointcuts  List of pointcuts referenced by this advice
38
 */
39
class Advice
40
{
41
42
    /**
43
     * Name of the aspect the advice is defined in
44
     *
45
     * @var string $aspectName
46
     */
47
    protected $aspectName;
48
49
    /**
50
     * The code hook this advice is designed for
51
     *
52
     * @var string $codeHook
53
     *
54
     * @Enum({"After", "AfterReturning", "AfterThrowing", "Around", "Before"})
55
     */
56
    protected $codeHook;
57
58
    /**
59
     * Name of the advice itself
60
     *
61
     * @var string $name
62
     */
63
    protected $name;
64
65
    /**
66
     * List of pointcuts referenced by this advice
67
     *
68
     * @var \AppserverIo\Doppelgaenger\Entities\Lists\TypedList $pointcuts
69
     */
70
    protected $pointcuts;
71
72
    /**
73
     * Default constructor
74
     */
75
    public function __construct()
76
    {
77
        $this->pointcuts = new TypedList('\AppserverIo\Doppelgaenger\Interfaces\PointcutInterface');
78
    }
79
80
    /**
81
     * Getter for the $aspectName property
82
     *
83
     * @return string
84
     */
85
    public function getAspectName()
86
    {
87
        return $this->aspectName;
88
    }
89
90
    /**
91
     * Getter for the $codeHook property
92
     *
93
     * @return string
94
     */
95
    public function getCodeHook()
96
    {
97
        return $this->codeHook;
98
    }
99
100
    /**
101
     * Getter for the $name property
102
     *
103
     * @return string
104
     */
105
    public function getName()
106
    {
107
        return $this->name;
108
    }
109
110
    /**
111
     * Getter for the $pointcuts property
112
     *
113
     * @return \AppserverIo\Doppelgaenger\Entities\Lists\TypedList
114
     */
115
    public function getPointcuts()
116
    {
117
        return $this->pointcuts;
118
    }
119
120
    /**
121
     * Will return the qualified name of an advice.
122
     * Will have the form or <CONTAINING ASPECT>-><ADVICE NAME>
123
     *
124
     * @return string
125
     */
126 View Code Duplication
    public function getQualifiedName()
127
    {
128
        if (empty($this->aspectName)) {
129
            return $this->name;
130
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
131
        } else {
132
            return $this->aspectName . '->' . $this->name;
133
        }
134
    }
135
136
    /**
137
     * Setter for the $aspectName property
138
     *
139
     * @param string $aspectName Name of the aspect the advice is defined in
140
     *
141
     * @return null
142
     */
143
    public function setAspectName($aspectName)
144
    {
145
        $this->aspectName = $aspectName;
146
    }
147
148
    /**
149
     * Setter for the $codeHook property
150
     *
151
     * @param string $codeHook The code hook this advice is designed for
152
     *
153
     * @return null
154
     */
155
    public function setCodeHook($codeHook)
156
    {
157
        $this->codeHook = $codeHook;
158
    }
159
160
    /**
161
     * Setter for the $name property
162
     *
163
     * @param string $name Name of the advice itself
164
     *
165
     * @return null
166
     */
167
    public function setName($name)
168
    {
169
        $this->name = $name;
170
    }
171
}
172