1 | <?php |
||
21 | class JsonGenerator extends AbstractASTVisitor implements CodeAwareGenerator, FileAwareGenerator |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $logFile; |
||
27 | |||
28 | /** |
||
29 | * @var AnalyzerProjectAware[] |
||
30 | */ |
||
31 | protected $projectAnalyzers = array(); |
||
32 | |||
33 | /** |
||
34 | * @var AnalyzerNodeAware[] |
||
35 | */ |
||
36 | protected $nodeAnalyzers = array(); |
||
37 | |||
38 | /** |
||
39 | * @var ASTArtifactList |
||
40 | */ |
||
41 | protected $artifacts; |
||
42 | |||
43 | /** |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $data = array(); |
||
47 | |||
48 | /** |
||
49 | * Project-wide totals for all node analyzers. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $projectMetrics = array(); |
||
54 | |||
55 | /** |
||
56 | * List of metrics to include and what to map them to. |
||
57 | * |
||
58 | * @var string[] |
||
59 | */ |
||
60 | protected $metrics = array( |
||
61 | 'eloc' => 'loc', |
||
62 | 'noc' => 'noc', |
||
63 | 'nom' => 'nom', |
||
64 | 'ca' => 'ca', |
||
65 | 'ce' => 'ce', |
||
66 | 'i' => 'i', |
||
67 | 'dit' => 'dit', |
||
68 | 'ccn2' => 'ccn', |
||
69 | 'npath' => 'npath', |
||
70 | 'he' => 'he', |
||
71 | 'hi' => 'hi', |
||
72 | 'mi' => 'mi', |
||
73 | ); |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | public function log(PDependAnalyzer $analyzer) |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | public function close() |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | public function getAcceptedAnalyzers() |
||
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | public function setLogFile($logFile) |
||
137 | |||
138 | /** |
||
139 | * {@inheritdoc} |
||
140 | */ |
||
141 | public function setArtifacts(ASTArtifactList $artifacts) |
||
145 | |||
146 | /** |
||
147 | * {@inheritdoc} |
||
148 | */ |
||
149 | public function visitNamespace(ASTNamespace $node) |
||
168 | |||
169 | /** |
||
170 | * {@inheritdoc} |
||
171 | */ |
||
172 | public function visitClass(ASTClass $node) |
||
176 | |||
177 | /** |
||
178 | * {@inheritdoc} |
||
179 | */ |
||
180 | public function visitTrait(ASTTrait $node) |
||
184 | |||
185 | /** |
||
186 | * {@inheritdoc} |
||
187 | */ |
||
188 | public function visitInterface(ASTInterface $node) |
||
192 | |||
193 | /** |
||
194 | * @param AbstractASTClassOrInterface $node |
||
195 | */ |
||
196 | protected function visitType(AbstractASTClassOrInterface $node) |
||
211 | |||
212 | /** |
||
213 | * {@inheritdoc} |
||
214 | */ |
||
215 | public function visitFunction(ASTFunction $node) |
||
224 | |||
225 | /** |
||
226 | * {@inheritdoc} |
||
227 | */ |
||
228 | public function visitMethod(ASTMethod $node) |
||
238 | |||
239 | /** |
||
240 | * @return int[] |
||
241 | */ |
||
242 | protected function getProjectMetrics() |
||
251 | |||
252 | /** |
||
253 | * @param ASTArtifact $node |
||
254 | * |
||
255 | * @return int[] |
||
256 | */ |
||
257 | protected function getNodeMetrics(ASTArtifact $node) |
||
277 | |||
278 | /** |
||
279 | * @param array $metrics |
||
280 | * |
||
281 | * @return array |
||
282 | */ |
||
283 | protected function normalizeMetrics(array $metrics) |
||
307 | |||
308 | /** |
||
309 | * pdepend.analyzer.dependency also calculates instability, but not on a |
||
310 | * per-class level, and defauling to 0 instead of 1. |
||
311 | * |
||
312 | * @param array $metrics |
||
313 | * |
||
314 | * @return array |
||
315 | */ |
||
316 | protected function addInstability(array $metrics) |
||
324 | } |
||
325 |