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 | * List of metrics to include and what to map them to. |
||
50 | * |
||
51 | * @var string[][] |
||
52 | */ |
||
53 | protected $metrics = array( |
||
54 | 'project' => array( |
||
55 | 'eloc' => 'loc', |
||
56 | 'noc' => 'noc', |
||
57 | 'nom' => 'nom', |
||
58 | 'nof' => 'nof', |
||
59 | ), |
||
60 | 'namespace' => array( |
||
61 | // nothing |
||
62 | ), |
||
63 | 'class' => array( |
||
64 | 'eloc' => 'loc', |
||
65 | 'ca' => 'ca', |
||
66 | 'ce' => 'ce', |
||
67 | 'i' => 'i', |
||
68 | 'dit' => 'dit', |
||
69 | ), |
||
70 | 'function' => array( |
||
71 | 'eloc' => 'loc', |
||
72 | 'ccn2' => 'ccn', |
||
73 | 'npath' => 'npath', |
||
74 | 'he' => 'he', |
||
75 | 'hi' => 'hi', |
||
76 | 'mi' => 'mi', |
||
77 | ), |
||
78 | ); |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function log(PDependAnalyzer $analyzer) |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function close() |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function getAcceptedAnalyzers() |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function setLogFile($logFile) |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function setArtifacts(ASTArtifactList $artifacts) |
||
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | public function visitNamespace(ASTNamespace $node) |
||
172 | |||
173 | /** |
||
174 | * {@inheritdoc} |
||
175 | */ |
||
176 | public function visitClass(ASTClass $node) |
||
180 | |||
181 | /** |
||
182 | * {@inheritdoc} |
||
183 | */ |
||
184 | public function visitTrait(ASTTrait $node) |
||
188 | |||
189 | /** |
||
190 | * {@inheritdoc} |
||
191 | */ |
||
192 | public function visitInterface(ASTInterface $node) |
||
196 | |||
197 | /** |
||
198 | * @param AbstractASTClassOrInterface $node |
||
199 | */ |
||
200 | protected function visitType(AbstractASTClassOrInterface $node) |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | public function visitFunction(ASTFunction $node) |
||
228 | |||
229 | /** |
||
230 | * {@inheritdoc} |
||
231 | */ |
||
232 | public function visitMethod(ASTMethod $node) |
||
242 | |||
243 | /** |
||
244 | * @return int[] |
||
245 | */ |
||
246 | protected function getProjectMetrics() |
||
255 | |||
256 | /** |
||
257 | * @param ASTArtifact $node |
||
258 | * @param string $type |
||
259 | * |
||
260 | * @return int[] |
||
261 | */ |
||
262 | protected function getNodeMetrics(ASTArtifact $node, $type) |
||
271 | |||
272 | /** |
||
273 | * @param array $metrics |
||
274 | * @param string $type |
||
275 | * |
||
276 | * @return array |
||
277 | */ |
||
278 | protected function normalizeMetrics(array $metrics, $type) |
||
300 | |||
301 | /** |
||
302 | * pdepend.analyzer.dependency also calculates instability, but not on a |
||
303 | * per-class level, and defaulting to 0 instead of 1. |
||
304 | * |
||
305 | * @param array $metrics |
||
306 | * |
||
307 | * @return array |
||
308 | */ |
||
309 | protected function addInstability(array $metrics) |
||
317 | } |
||
318 |