1 | <?php |
||
10 | class Analyzer |
||
11 | { |
||
12 | /** |
||
13 | * pdepend XML filename. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $xml = 'pdepend.xml'; |
||
18 | |||
19 | /** |
||
20 | * cauditor JSON filename. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $json = 'cauditor.json'; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $buildPath; |
||
30 | |||
31 | /** |
||
32 | * @var Config |
||
33 | */ |
||
34 | protected $config; |
||
35 | |||
36 | /** |
||
37 | * @param Config $config |
||
38 | * |
||
39 | * @throws Exception |
||
40 | */ |
||
41 | public function __construct(Config $config) |
||
49 | |||
50 | /** |
||
51 | * @param string $api |
||
52 | * |
||
53 | * @return string|bool API response (on success) or false (on failure) |
||
54 | * |
||
55 | * @throws Exception |
||
56 | */ |
||
57 | public function run($api) |
||
79 | |||
80 | /** |
||
81 | * Runs pdepend to generate the metrics. |
||
82 | * |
||
83 | * @throws Exception |
||
84 | */ |
||
85 | protected function pdepend() |
||
97 | |||
98 | /** |
||
99 | * Fetch build data from CI. |
||
100 | * |
||
101 | * @return string[] |
||
102 | * |
||
103 | * @throws Exception |
||
104 | */ |
||
105 | protected function sniff() |
||
114 | |||
115 | /** |
||
116 | * Transform pdepend output into the (more succinct) format cauditor |
||
117 | * understands. |
||
118 | * |
||
119 | * @param string $xml |
||
120 | * |
||
121 | * @return string |
||
122 | * |
||
123 | * @throws Exception |
||
124 | */ |
||
125 | protected function convert($xml) |
||
137 | |||
138 | /** |
||
139 | * Submit the data to cauditor API. |
||
140 | * |
||
141 | * @param string $api |
||
142 | * @param string[] $data |
||
143 | * |
||
144 | * @return string|bool API response (on success) or false (on failure) |
||
145 | */ |
||
146 | protected function transmit($api, $data) |
||
163 | } |
||
164 |