Completed
Push — master ( 05283a...49c7da )
by Victor
12s
created

TextFileWriter::writeFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace LazyEight\DiTesto;
4
5
use LazyEight\DiTesto\Exceptions\IOException;
6
use LazyEight\DiTesto\Interfaces\FileWriterInterface;
7
use LazyEight\DiTesto\Interfaces\WritableFileInterface;
8
9
class TextFileWriter implements FileWriterInterface
10
{
11
    /**
12
     * @inheritDoc
13
     */
14 2
    public function writeFile(WritableFileInterface $file)
15
    {
16 2
        if (!$file->isWritable()) {
17 1
            throw new IOException("Can't write the file. Permission denied");
18
        }
19
20 1
        $file->write();
21 1
    }
22
}
23