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

FileContentIo::filePutContents()   A

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
/**
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