1 | <?php |
||
10 | abstract class AbstractIntegration |
||
11 | { |
||
12 | /** |
||
13 | * Directory path to where the bin scripts are located. |
||
14 | * @var string directory path. |
||
15 | */ |
||
16 | protected $binariesPath; |
||
17 | |||
18 | /** |
||
19 | * Temporary file wherein the output will be written |
||
20 | * @var string temporary file path. |
||
21 | */ |
||
22 | protected $temporaryFilePath; |
||
23 | |||
24 | /** |
||
25 | * Paths to be ignored during runtime. |
||
26 | * @var array target file or directory paths to be ignored. |
||
27 | */ |
||
28 | protected $ignoredPaths; |
||
29 | |||
30 | /** |
||
31 | * Analysis result for this integration. |
||
32 | * @var AnalysisResult result object. |
||
33 | */ |
||
34 | protected $result; |
||
35 | |||
36 | /** |
||
37 | * Stores binaries path. |
||
38 | * @param string $binariesPath where the bin scripts are located. |
||
39 | * @param string $temporaryDirPath where temporary files will be created. |
||
40 | */ |
||
41 | public function __construct($binariesPath, $temporaryDirPath) |
||
48 | |||
49 | /** |
||
50 | * Ignore informed targets during execution. |
||
51 | * @param array $targets target file or directory paths to be ignored. |
||
52 | * @return void |
||
53 | */ |
||
54 | public function setIgnoredPaths(array $targets) |
||
58 | |||
59 | /** |
||
60 | * Analysis results for this integration. |
||
61 | * @return AnalysisResult analysis result object. |
||
62 | */ |
||
63 | public function getAnalysisResult() |
||
67 | |||
68 | /** |
||
69 | * Creates and execute tool command, returning output results. |
||
70 | * @param string[] $targetPaths file/directory paths to be analysed. |
||
71 | * @return string CLI JSON output. |
||
72 | */ |
||
73 | public function run($targetPaths) |
||
78 | |||
79 | /** |
||
80 | * Prepare and execute command. |
||
81 | * @param string[] $targetPaths file/directory paths to be analysed. |
||
82 | * @return void |
||
83 | */ |
||
84 | protected function executeCommand($targetPaths) |
||
88 | |||
89 | /** |
||
90 | * Convert tool output into PHP Hound array output. |
||
91 | * @return void |
||
92 | */ |
||
93 | protected function processResults() |
||
103 | |||
104 | /** |
||
105 | * Tool raw output. |
||
106 | * @return string raw output contents. |
||
107 | */ |
||
108 | protected function getOutputContent() |
||
112 | |||
113 | /** |
||
114 | * Integration description. |
||
115 | * @return string description. |
||
116 | */ |
||
117 | abstract public function getDescription(); |
||
118 | |||
119 | /** |
||
120 | * Create integration command to be run on the shell. |
||
121 | * @param string[] $targetPaths file/directory paths to be analysed. |
||
122 | * @return string shell command. |
||
123 | */ |
||
124 | abstract public function getCommand($targetPaths); |
||
125 | |||
126 | /** |
||
127 | * Read issues from the XML output. |
||
128 | * @param Reader $xml XML reader object. |
||
129 | * @return void |
||
130 | */ |
||
131 | abstract protected function addIssuesFromXml(Reader $xml); |
||
132 | } |
||
133 |