OutputFileJson::process()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 4
nc 3
nop 0
1
<?php
2
3
namespace  SchemaGenerate\StructureGenerate\Outputs;
4
5
class OutputFileJson extends OutputAbstract
6
{
7
    public function process(): array
8
    {
9
        foreach ($this->settings as $key => $filePath) {
10
            $concurrentDirectory = str_replace(basename($filePath), '', $filePath);
11
            if (!is_dir($concurrentDirectory) && !mkdir($concurrentDirectory, 0777, true)) {
12
                throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
13
            }
14
15
            file_put_contents($filePath, json_encode($this->data->get($key)));
16
        }
17
        return $this->settings;
18
    }
19
}