Passed
Push — master ( b4202c...ce7bde )
by Yo!
02:48
created

Filesystem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 24
ccs 4
cts 6
cp 0.6667
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A readFile() 0 11 3
1
<?php
2
3
/*
4
 * This file is part of the Yosymfony\Spress.
5
 *
6
 * (c) YoSymfony <http://github.com/yosymfony>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Yosymfony\Spress\Core\Support;
13
14
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
15
use Symfony\Component\Filesystem\Exception\IOException;
16
use Symfony\Component\Filesystem\Filesystem as FilesystemBase;
17
18
/**
19
 * An extension for Symfony Filesystem component.
20
 */
21
class Filesystem extends FilesystemBase
22
{
23
    /**
24
     * Reads the content of a filename.
25
     *
26
     * @param string The file to which to read the content.
27
     *
28
     * @return string The content of the filename.
29
     *
30
     * @throws FileNotFoundException When the filename does not exist.
31
     * @throws IOException           When the filename cannot be read.
32
     */
33 1
    public function readFile($filename)
34
    {
35 1
        if (is_file($filename) === false) {
36
            throw new FileNotFoundException(sprintf('File "%s" does not exist.', $filename));
37
        }
38 1
        if (is_readable($filename) === false) {
39
            throw new IOException(sprintf('File "%s" cannot be read.', $filename));
40
        }
41
42 1
        return file_get_contents($filename);
43
    }
44
}
45