Filesystem   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
cbo 2
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 8 2
A write() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Bowerphp.
5
 *
6
 * (c) Massimiliano Arione <[email protected]>
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 Bowerphp\Util;
13
14
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
15
use Symfony\Component\Filesystem\Filesystem as BaseFilesystem;
16
17
/**
18
 * Filesystem
19
 */
20
class Filesystem extends BaseFilesystem
21
{
22
    /**
23
     * Read a file
24
     *
25
     * @param string $filename
26
     *
27
     * @return string
28
     */
29
    public function read($filename)
30
    {
31
        if (!is_readable($filename)) {
32
            throw new FileNotFoundException(sprintf('File "%s" does not exist.', $filename), 0, null, $filename);
33
        }
34
35
        return file_get_contents($filename);
36
    }
37
38
    /**
39
     * Write a file
40
     *
41
     * @param string $filename The file to be written to
42
     * @param string $content  The data to write into the file
43
     * @param int    $mode     The file mode (octal)
44
     *
45
     * @throws \Symfony\Component\Filesystem\Exception\IOException If the file cannot be written to
46
     */
47
    public function write($filename, $content, $mode = 0644)
48
    {
49
        $this->dumpFile($filename, $content);
50
    }
51
}
52