Completed
Push — master ( 49c7da...61b9c9 )
by Victor
13s
created

FileWriter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 11
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A writeFile() 0 8 2
1
<?php
2
3
namespace LazyEight\DiTesto;
4
5
use LazyEight\DiTesto\Exceptions\IOException;
6
use LazyEight\DiTesto\Interfaces\FileInterface;
7
use LazyEight\DiTesto\Interfaces\FileSystem\FileSystemHandlerInterface;
8
use LazyEight\DiTesto\Interfaces\FileWriterInterface;
9
use LazyEight\DiTesto\Interfaces\WritableFileInterface;
10
11
class FileWriter implements FileWriterInterface
12
{
13
    public function writeFile(FileInterface $file, FileSystemHandlerInterface $fileSystemHandler)
14
    {
15
        if (!$fileSystemHandler->isWritable($file->getPath())) {
16
            throw new IOException("Error, can't write to the file. The file not exists or is not writable.");
17
        }
18
19
        $fileSystemHandler->write($file->getPath(), $file->getRawContent());
20
    }
21
}
22