Skip to content

Commit ce6ccab

Browse files
committed
Returning JSON from JsonGenerator - can be used for tests
1 parent d7e6c7b commit ce6ccab

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Generator/JsonGenerator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ public function __construct(Metas $metas, BuildConfig $buildConfig)
3737
$this->buildConfig = $buildConfig;
3838
}
3939

40-
public function generateJson()
40+
/**
41+
* Returns an array of each JSON file string, keyed by the input filename
42+
*
43+
* @return string[]
44+
*/
45+
public function generateJson(): array
4146
{
4247
$fs = new Filesystem();
4348

4449
$progressBar = new ProgressBar($this->output ?: new NullOutput());
4550
$progressBar->setMaxSteps(\count($this->metas->getAll()));
4651

52+
$fJsonFiles = [];
4753
foreach ($this->metas->getAll() as $filename => $metaEntry) {
4854
$parserFilename = $filename;
4955
$jsonFilename = $this->buildConfig->getOutputDir().'/'.$filename.'.fjson';
@@ -67,11 +73,14 @@ public function generateJson()
6773
$jsonFilename,
6874
json_encode($data, JSON_PRETTY_PRINT)
6975
);
76+
$fJsonFiles[$filename] = json_encode($data, JSON_PRETTY_PRINT);
7077

7178
$progressBar->advance();
7279
}
7380

7481
$progressBar->finish();
82+
83+
return $fJsonFiles;
7584
}
7685

7786
public function setOutput(SymfonyStyle $output)

0 commit comments

Comments
 (0)