Completed
Push — nln-php7 ( 6680df...1a6b54 )
by Nicolas
02:06
created

SingleLocalFile   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 1
dl 0
loc 62
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Karma\Filesystem\Adapters;
6
7
use Gaufrette\Adapter;
8
9
class SingleLocalFile implements Adapter
10
{
11
    private string
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

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