Completed
Push — master ( 993468...5fd9a9 )
by Markus
12s queued 10s
created

Filesystem   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 74
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A mkdir() 0 5 1
A writeToFile() 0 5 1
A __construct() 0 3 1
A exists() 0 3 1
A appendToFile() 0 5 1
A remove() 0 5 1
1
<?php
2
3
namespace Jellyfish\FilesystemSymfony;
4
5
use Jellyfish\Filesystem\FilesystemInterface;
6
use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
7
8
class Filesystem implements FilesystemInterface
9
{
10
    /**
11
     * @var \Symfony\Component\Filesystem\Filesystem
12
     */
13
    protected $symfonyFilesystem;
14
15
    /**
16
     * @param \Symfony\Component\Filesystem\Filesystem $symfonyFilesystem
17
     */
18
    public function __construct(SymfonyFilesystem $symfonyFilesystem)
19
    {
20
        $this->symfonyFilesystem = $symfonyFilesystem;
21
    }
22
23
    /**
24
     * @param string $path
25
     * @param int $mode
26
     *
27
     * @return \Jellyfish\Filesystem\FilesystemInterface
28
     */
29
    public function mkdir(string $path, int $mode = 0777): FilesystemInterface
30
    {
31
        $this->symfonyFilesystem->mkdir($path, $mode);
32
33
        return $this;
34
    }
35
36
    /**
37
     * @param string $path
38
     *
39
     * @return \Jellyfish\Filesystem\FilesystemInterface
40
     */
41
    public function remove(string $path): FilesystemInterface
42
    {
43
        $this->symfonyFilesystem->remove($path);
44
45
        return $this;
46
    }
47
48
    /**
49
     * @param string $path
50
     *
51
     * @return bool
52
     */
53
    public function exists(string $path): bool
54
    {
55
        return $this->symfonyFilesystem->exists($path);
56
    }
57
58
    /**
59
     * @param string $pathToFile
60
     * @param string $content
61
     *
62
     * @return \Jellyfish\Filesystem\FilesystemInterface
63
     */
64
    public function appendToFile(string $pathToFile, string $content): FilesystemInterface
65
    {
66
        $this->symfonyFilesystem->appendToFile($pathToFile, $content);
67
68
        return $this;
69
    }
70
71
    /**
72
     * @param string $pathToFile
73
     * @param string $content
74
     *
75
     * @return \Jellyfish\Filesystem\FilesystemInterface
76
     */
77
    public function writeToFile(string $pathToFile, string $content): FilesystemInterface
78
    {
79
        $this->symfonyFilesystem->dumpFile($pathToFile, $content);
80
81
        return $this;
82
    }
83
}
84