OutputFileJson   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 11 4
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
}