Filesystem   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A overwrite() 0 4 1
A make() 0 8 2
A get() 0 3 1
A put() 0 3 1
1
<?php
2
3
namespace Acacha\Llum\Filesystem;
4
5
/**
6
 * Class Filesystem
7
 */
8
/**
9
 * Class Filesystem
10
 * @package Acacha\Llum\Filesystem
11
 */
12
class Filesystem
13
{
14
15
    /**
16
     *
17
     * Overwrite file with provided content.
18
     *
19
     * @param $file
20
     * @param $content
21
     */
22
    public function overwrite($file, $content)
23
    {
24
        $this->put($file, $content);
25
    }
26
27
    /**
28
     * Create file with provided content if not exists.
29
     *
30
     * @param $file
31
     * @param $content
32
     * @throws FileAlreadyExists
33
     */
34
    public function make($file, $content)
35
    {
36
        if ( $this->exists($file))
0 ignored issues
show
Bug introduced by
The method exists() does not seem to exist on object<Acacha\Llum\Filesystem\Filesystem>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        {
38
            throw new FileAlreadyExists;
39
        }
40
        $this->put($file, $content);
41
    }
42
43
    /**
44
     * Get file contents
45
     */
46
    public function get($file) {
47
        return file_get_contents($file);
48
    }
49
50
    /**
51
     * Put content in file.
52
     *
53
     * @param $file
54
     * @param $content
55
     * @return int
56
     */
57
    protected function put($file, $content) {
58
        return file_put_contents($file, $content);
59
    }
60
}