FileContentIo   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mkdir() 0 15 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
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