Completed
Push — singleFile ( a2a23d )
by Nicolas
10:41
created

SingleLocalFile::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Karma\Filesystem\Adapters;
4
5
use Gaufrette\Adapter;
6
7
class SingleLocalFile implements Adapter
8
{
9
    private
10
        $filename,
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
11
        $adapter;
12
13
    public function __construct($filename, Adapter $adapter)
14
    {
15
        $this->filename = $filename;
16
        $this->adapter = $adapter;
17
    }
18
19
    public function read($key)
20
    {
21
        if(! $this->exists($key))
22
        {
23
            return false;
24
        }
25
26
        return $this->adapter->read($key);
27
    }
28
29
    public function write($key, $content)
30
    {
31
        return $this->adapter->write($key, $content);
32
    }
33
34
    public function exists($key)
35
    {
36
        return $key === $this->filename;
37
    }
38
39
    public function keys()
40
    {
41
        return [$this->filename];
42
    }
43
44
    public function mtime($key)
45
    {
46
        if(! $this->exists($key))
47
        {
48
            return false;
49
        }
50
51
        return $this->adapter->mtime($key);
52
    }
53
54
    public function delete($key)
55
    {
56
        throw new \RuntimeException('Not implemented yet : ' . __METHOD__);
57
    }
58
59
    public function rename($sourceKey, $targetKey)
60
    {
61
        throw new \RuntimeException('Not implemented yet : ' . __METHOD__);
62
    }
63
64
    public function isDirectory($key)
65
    {
66
        return false;
67
    }
68
}
69