FileContentIo::filePutContents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
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
use function sprintf;
11
12
/**
13
 * @codeCoverageIgnore
14
 */
15
final class FileContentIo implements FileContentIoInterface
16
{
17
    public function mkdir(string $directory): void
18
    {
19
        if (is_dir($directory)) {
20
            return;
21
        }
22
23
        if (mkdir($directory)) {
24
            return;
25
        }
26
27
        if (is_dir($directory)) {
28
            return;
29
        }
30
31
        throw new RuntimeException(sprintf('Directory "%s" was not created', $directory));
32
    }
33
34
    public function filePutContents(string $path, string $fileContent): void
35
    {
36
        file_put_contents($path, $fileContent);
37
    }
38
}
39