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

FileContentIo   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mkdir() 0 7 4
A filePutContents() 0 3 1
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