@@ -14,7 +14,7 @@ class AutocompleteCommand extends Command
14
14
15
15
public function handle (): void
16
16
{
17
- $ code = $ this ->argument ('code ' );
17
+ $ code = base64_decode ( $ this ->argument ('code ' ) );
18
18
19
19
if ($ this ->option ('from-file ' )) {
20
20
$ code = file_get_contents (__DIR__ . '/../../tests/snippets/parse/ ' . $ this ->option ('from-file ' ) . '.php ' );
@@ -26,23 +26,23 @@ public function handle(): void
26
26
$ autocompleting = $ result ->findAutocompleting ();
27
27
28
28
if (app ()->isLocal ()) {
29
- $ dir = 'local-results/autocomplete ' ;
30
- File::ensureDirectoryExists (storage_path ($ dir ));
31
- $ now = now ()->format ('Y-m-d-H-i-s ' );
32
-
33
- if (!$ this ->option ('from-file ' )) {
34
- File::put (storage_path ("{$ dir }/ {$ now }-01-code.php " ), $ code );
35
- }
36
-
37
- File::put (storage_path ("{$ dir }/ {$ now }-02-autocomplete.json " ), json_encode ($ autocompleting ?->flip() ?? [], JSON_PRETTY_PRINT ));
38
- File::put (storage_path ("{$ dir }/ {$ now }-03-full.json " ), $ result ->toJson (JSON_PRETTY_PRINT ));
29
+ $ this ->log ($ autocompleting , $ result , $ code );
39
30
}
40
31
41
32
echo json_encode ($ autocompleting ?->flip() ?? [], $ this ->option ('debug ' ) ? JSON_PRETTY_PRINT : 0 );
33
+ }
42
34
43
- // dd($autocompleting->flip(), 'Autocompleting');
44
- // // $toAutocomplete = $this->findFirstAutocompleting($result->toArray()['children']);
35
+ protected function log ($ autocompleting , $ result , $ code )
36
+ {
37
+ $ dir = 'local-results/autocomplete ' ;
38
+ File::ensureDirectoryExists (storage_path ($ dir ));
39
+ $ now = now ()->format ('Y-m-d-H-i-s ' );
40
+
41
+ if (!$ this ->option ('from-file ' )) {
42
+ File::put (storage_path ("{$ dir }/ {$ now }-01-code.php " ), $ code );
43
+ }
45
44
46
- // echo $result->toJson($this->option('debug') ? JSON_PRETTY_PRINT : 0);
45
+ File::put (storage_path ("{$ dir }/ {$ now }-02-autocomplete.json " ), json_encode ($ autocompleting ?->flip() ?? [], JSON_PRETTY_PRINT ));
46
+ File::put (storage_path ("{$ dir }/ {$ now }-03-full.json " ), $ result ->toJson (JSON_PRETTY_PRINT ));
47
47
}
48
48
}
0 commit comments