Completed
Pull Request — master (#12)
by Victor
01:54
created

FileReader::readFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 6
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\FileReaderInterface;
8
use LazyEight\DiTesto\Interfaces\FileSystem\FileSystemHandlerInterface;
9
10
class FileReader implements FileReaderInterface
11
{
12
    /**
13
     * @inheritDoc
14
     */
15
    public function readFile(FileInterface $file, FileSystemHandlerInterface $fileSystemHandler)
16
    {
17
        if (!$fileSystemHandler->isReadable($file->getPath())) {
18
            throw new IOException("Error, can't read the file. The file not exist or is not readable.");
19
        }
20
21
        $file->setRawContent($fileSystemHandler->read($file->getPath()));
22
    }
23
}
24