Passed
Push — feature/create-console-bootstr... ( abaeda )
by Chema
04:15
created

FileContentIo::mkdir()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 4
nc 3
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Console\Infrastructure;
6
7
use Gacela\Console\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