Passed
Push — feature/add-config-files ( 837ed6...2054b6 )
by Jesús
11:11 queued 06:36
created

FileContentIo::mkdir()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 4
c 2
b 0
f 0
nc 3
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\CodeGenerator\Infrastructure;
6
7
use Gacela\CodeGenerator\Domain\FileContent\FileContentIoInterface;
8
use RuntimeException;
9
10
/**
11
 * @codeCoverageIgnore
12
 */
13
final class FileContentIo implements FileContentIoInterface
14
{
15
    public function mkdir(string $directory): void
16
    {
17
        if (is_dir($directory)) {
18
            return;
19
        }
20
        if (!mkdir($directory) && !is_dir($directory)) {
21
            throw new RuntimeException(sprintf('Directory "%s" was not created', $directory));
22
        }
23
    }
24
25
    public function filePutContents(string $path, string $fileContent): void
26
    {
27
        file_put_contents($path, $fileContent);
28
    }
29
}
30