1 | <?php |
||
28 | class RuleViolation |
||
29 | { |
||
30 | /** |
||
31 | * The rule that causes this violation. |
||
32 | * |
||
33 | * @var \PHPMD\Rule |
||
34 | */ |
||
35 | private $rule; |
||
36 | |||
37 | /** |
||
38 | * The context code node for this rule violation. |
||
39 | * |
||
40 | * @var \PHPMD\AbstractNode |
||
41 | */ |
||
42 | private $node; |
||
43 | |||
44 | /** |
||
45 | * The description/message text that describes the violation. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | private $description; |
||
50 | |||
51 | /** |
||
52 | * The raw metric value which caused this rule violation. |
||
53 | * |
||
54 | * @var mixed |
||
55 | */ |
||
56 | private $metric; |
||
57 | |||
58 | /** |
||
59 | * Name of the owning/context class or interface of this violation. |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | private $className = null; |
||
64 | |||
65 | /** |
||
66 | * The name of a method or <b>null</b> when this violation has no method |
||
67 | * context. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | private $methodName = null; |
||
72 | |||
73 | /** |
||
74 | * The name of a function or <b>null</b> when this violation has no function |
||
75 | * context. |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | private $functionName = null; |
||
80 | |||
81 | /** |
||
82 | * Constructs a new rule violation instance. |
||
83 | * |
||
84 | * @param \PHPMD\Rule $rule |
||
85 | * @param \PHPMD\AbstractNode $node |
||
86 | * @param string $violationMessage |
||
87 | * @param mixed $metric |
||
88 | */ |
||
89 | 33 | public function __construct(Rule $rule, AbstractNode $node, $violationMessage, $metric = null) |
|
105 | |||
106 | /** |
||
107 | * Returns the rule that causes this violation. |
||
108 | * |
||
109 | * @return \PHPMD\Rule |
||
110 | */ |
||
111 | public function getRule() |
||
112 | { |
||
113 | return $this->rule; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Returns the description/message text that describes the violation. |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | 6 | public function getDescription() |
|
125 | |||
126 | /** |
||
127 | * Returns the raw metric value which caused this rule violation. |
||
128 | * |
||
129 | * @return mixed|null |
||
130 | */ |
||
131 | public function getMetric() |
||
135 | |||
136 | /** |
||
137 | * Returns the file name where this rule violation was detected. |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | 6 | public function getFileName() |
|
145 | |||
146 | /** |
||
147 | * Returns the first line of the node that causes this rule violation. |
||
148 | * |
||
149 | * @return integer |
||
150 | */ |
||
151 | 6 | public function getBeginLine() |
|
155 | |||
156 | /** |
||
157 | * Returns the last line of the node that causes this rule violation. |
||
158 | * |
||
159 | * @return integer |
||
160 | */ |
||
161 | public function getEndLine() |
||
165 | |||
166 | /** |
||
167 | * Returns the name of the package that contains this violation. |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getNamespaceName() |
||
175 | |||
176 | /** |
||
177 | * Returns the name of the parent class or interface or <b>null</b> when there |
||
178 | * is no parent class. |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getClassName() |
||
186 | |||
187 | /** |
||
188 | * Returns the name of a method or <b>null</b> when this violation has no |
||
189 | * method context. |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | public function getMethodName() |
||
197 | |||
198 | /** |
||
199 | * Returns the name of a function or <b>null</b> when this violation has no |
||
200 | * function context. |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | public function getFunctionName() |
||
208 | } |
||
209 |