1 | <?php declare(strict_types=1); |
||
9 | class ResourceGenerator |
||
10 | { |
||
11 | /** |
||
12 | * @var callable |
||
13 | */ |
||
14 | protected $out = 'ApiClients\Tools\ResourceGenerator\outln'; |
||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $configuration; |
||
20 | |||
21 | /** |
||
22 | * @var FileGeneratorInterface[] |
||
23 | */ |
||
24 | protected $generators = []; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $pathSrc; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $pathTests; |
||
35 | |||
36 | /** |
||
37 | * @var Fixer |
||
38 | */ |
||
39 | protected $fixer; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $fixers; |
||
45 | |||
46 | 1 | public function __construct(array $configuration, callable $out = null) |
|
55 | |||
56 | 1 | public function run() |
|
66 | |||
67 | 1 | protected function applyAnnotationsToDefinition(array $definition): array |
|
102 | |||
103 | /** |
||
104 | * @param array $file |
||
105 | * @throws Exception |
||
106 | */ |
||
107 | 1 | protected function generateFromDefinition(array $file) |
|
134 | |||
135 | /** |
||
136 | * @param Node $node |
||
137 | * @return string |
||
138 | */ |
||
139 | 1 | protected function printCode(Node $node): string |
|
146 | |||
147 | /** |
||
148 | * @param string $fileName |
||
149 | * @param string $fileContents |
||
150 | * @return bool |
||
151 | * @throws Exception |
||
152 | */ |
||
153 | 1 | protected function save(string $fileName, string $fileContents) |
|
179 | |||
180 | /** |
||
181 | * @param string $fileName |
||
182 | */ |
||
183 | 1 | protected function applyPsr2($fileName) |
|
184 | { |
||
185 | 1 | $fileName = $this->configuration['root'] . $fileName; |
|
186 | |||
187 | $command = 'vendor/bin/php-cs-fixer fix ' . |
||
188 | 1 | $fileName . |
|
189 | 1 | ' --config=' . |
|
190 | 1 | dirname(__DIR__) . |
|
191 | 1 | DIRECTORY_SEPARATOR . |
|
192 | 1 | '.php_cs ' . |
|
193 | 1 | ' --allow-risky=yes -q -v --stop-on-violation --using-cache=no'; |
|
194 | |||
195 | 1 | system($command); |
|
196 | 1 | } |
|
197 | |||
198 | 1 | private function out(string $message) |
|
203 | } |
||
204 |