1 | <?php |
||
15 | class ConvertCommand extends AbstractSchemaCommand |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * Filesystem handler |
||
20 | * |
||
21 | * @var Filesystem $filesystem |
||
22 | */ |
||
23 | private $filesystem; |
||
24 | |||
25 | /** |
||
26 | * Path to request entity templates |
||
27 | * |
||
28 | * @var string $templatePath |
||
29 | */ |
||
30 | private $templatePath; |
||
31 | |||
32 | /** |
||
33 | * Default path to folder with schemas |
||
34 | * |
||
35 | * @var string $schemaPath |
||
36 | */ |
||
37 | private $schemaPath; |
||
38 | |||
39 | /** |
||
40 | * Default path to folder where generated requests will be stored |
||
41 | * |
||
42 | * @var string $publishPath |
||
43 | */ |
||
44 | private $publishPath; |
||
45 | |||
46 | /** |
||
47 | * Default namespace |
||
48 | * |
||
49 | * @var string $namespace |
||
50 | */ |
||
51 | private $namespace; |
||
52 | |||
53 | /** |
||
54 | * The name and signature of the console command |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $signature = 'schema:convert'; |
||
59 | |||
60 | /** |
||
61 | * The console command description |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $description = 'Converts JSON schema to request entity'; |
||
66 | |||
67 | /** |
||
68 | * Maps JSON schema type to PHP internal type |
||
69 | * |
||
70 | * @param string[]|string $type |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | private function toPhpInternalType($type) |
||
97 | |||
98 | /** |
||
99 | * Maps PHP internal type to JMS type |
||
100 | * |
||
101 | * @param string[]|string $type |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | private function toJmsType($type) |
||
120 | |||
121 | /** |
||
122 | * Handles all properties specified in JSON schema |
||
123 | * |
||
124 | * @param array $schema |
||
125 | * |
||
126 | * @return string |
||
127 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
||
128 | */ |
||
129 | private function prepareProperties(array $schema) |
||
153 | |||
154 | /** |
||
155 | * Handles all getter methods for properties specified in JSON schema |
||
156 | * |
||
157 | * @param array $schema |
||
158 | * |
||
159 | * @return string |
||
160 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
||
161 | */ |
||
162 | private function prepareMethods(array $schema) |
||
192 | |||
193 | /** |
||
194 | * Replaces data in templates to actual code |
||
195 | * |
||
196 | * @param array $what |
||
197 | * @param string $template |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | private function replace(array $what, $template) |
||
209 | |||
210 | /** |
||
211 | * @inheritdoc |
||
212 | */ |
||
213 | public function __construct(Filesystem $filesystem) |
||
227 | |||
228 | /** |
||
229 | * Converts JSON schema to request entity |
||
230 | * |
||
231 | * @throws \InvalidArgumentException |
||
232 | * @throws \UnexpectedValueException |
||
233 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
||
234 | */ |
||
235 | public function handle() |
||
274 | |||
275 | } |
||
276 |