Completed
Pull Request — master (#1)
by Albin
01:57
created

ResolvableFilesystem   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 159
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 19
lcom 2
cbo 3
dl 0
loc 159
rs 10
c 0
b 0
f 0

18 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A resolve() 0 8 2
A has() 0 4 1
A rename() 0 4 1
A get() 0 4 1
A write() 0 4 1
A read() 0 4 1
A delete() 0 4 1
A keys() 0 4 1
A listKeys() 0 4 1
A mtime() 0 4 1
A checksum() 0 4 1
A size() 0 4 1
A createStream() 0 4 1
A createFile() 0 4 1
A mimeType() 0 4 1
A isDirectory() 0 4 1
A __call() 0 4 1
1
<?php
2
3
namespace Gaufrette\Extras\Resolvable;
4
5
use Gaufrette\FilesystemInterface;
6
7
class ResolvableFilesystem implements FilesystemInterface
8
{
9
    /** @var FilesystemInterface */
10
    private $decorated;
11
12
    /** @var ResolverInterface */
13
    private $resolver;
14
15
    public function __construct(FilesystemInterface $decorated, ResolverInterface $resolver)
16
    {
17
        $this->decorated = $decorated;
18
        $this->resolver  = $resolver;
19
    }
20
21
    /**
22
     * @param string $key Object path.
23
     *
24
     * @throws UnresolvableObjectException When not able to resolve the object path. Any exception thrown by underlying
25
     *                                     resolver will be converted to this exception.
26
     *
27
     * @return string
28
     */
29
    public function resolve($key)
30
    {
31
        try {
32
            return $this->resolver->resolve($key);
33
        } catch (\Exception $e) {
34
            throw new UnresolvableObjectException($key, $e);
35
        }
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function has($key)
42
    {
43
        return $this->decorated->has($key);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function rename($sourceKey, $targetKey)
50
    {
51
        return $this->decorated->rename($sourceKey, $targetKey);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function get($key, $create = false)
58
    {
59
        return $this->decorated->get($key, $create);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function write($key, $content, $overwrite = false)
66
    {
67
        return $this->decorated->write($key, $content, $overwrite);
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function read($key)
74
    {
75
        return $this->decorated->read($key);
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function delete($key)
82
    {
83
        return $this->decorated->delete($key);
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function keys()
90
    {
91
        return $this->decorated->keys();
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function listKeys($prefix = '')
98
    {
99
        return $this->decorated->listKeys($prefix);
100
    }
101
102
    /**
103
     * {@inheritdoc}
104
     */
105
    public function mtime($key)
106
    {
107
        return $this->decorated->mtime($key);
108
    }
109
110
    /**
111
     * {@inheritdoc}
112
     */
113
    public function checksum($key)
114
    {
115
        return $this->decorated->checksum($key);
116
    }
117
118
    /**
119
     * {@inheritdoc}
120
     */
121
    public function size($key)
122
    {
123
        return $this->decorated->size($key);
124
    }
125
126
    /**
127
     * {@inheritdoc}
128
     */
129
    public function createStream($key)
130
    {
131
        return $this->decorated->createStream($key);
132
    }
133
134
    /**
135
     * {@inheritdoc}
136
     */
137
    public function createFile($key)
138
    {
139
        return $this->decorated->createFile($key);
140
    }
141
142
    /**
143
     * {@inheritdoc}
144
     */
145
    public function mimeType($key)
146
    {
147
        return $this->decorated->mimeType($key);
148
    }
149
150
    /**
151
     * {@inheritdoc}
152
     */
153
    public function isDirectory($key)
154
    {
155
        return $this->decorated->isDirectory($key);
156
    }
157
158
    /**
159
     * {@inheritdoc}
160
     */
161
    function __call($name, $arguments)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
162
    {
163
        return call_user_func_array([$this->decorated, $name], $arguments);
164
    }
165
}
166