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

FileContentIo::filePutContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 2
dl 0
loc 3
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