Handler   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 128
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 128
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isDir() 0 4 1
A isFile() 0 4 1
A getType() 0 6 1
A setFilesystem() 0 6 1
A getFilesystem() 0 4 1
A setPath() 0 6 1
A getPath() 0 4 1
A __call() 0 15 2
1
<?php
2
3
namespace League\Flysystem;
4
5
use BadMethodCallException;
6
7
/**
8
 * @deprecated
9
 */
10
abstract class Handler
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $path;
16
17
    /**
18
     * @var FilesystemInterface
19
     */
20
    protected $filesystem;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param FilesystemInterface $filesystem
26
     * @param string              $path
27
     */
28 117
    public function __construct(FilesystemInterface $filesystem = null, $path = null)
29
    {
30 117
        $this->path = $path;
31 117
        $this->filesystem = $filesystem;
32 117
    }
33
34
    /**
35
     * Check whether the entree is a directory.
36
     *
37
     * @return bool
38
     */
39 3
    public function isDir()
40
    {
41 3
        return $this->getType() === 'dir';
42
    }
43
44
    /**
45
     * Check whether the entree is a file.
46
     *
47
     * @return bool
48
     */
49 3
    public function isFile()
50
    {
51 3
        return $this->getType() === 'file';
52
    }
53
54
    /**
55
     * Retrieve the entree type (file|dir).
56
     *
57
     * @return string file or dir
58
     */
59 6
    public function getType()
60
    {
61 6
        $metadata = $this->filesystem->getMetadata($this->path);
62
63 6
        return $metadata['type'];
64
    }
65
66
    /**
67
     * Set the Filesystem object.
68
     *
69
     * @param FilesystemInterface $filesystem
70
     *
71
     * @return $this
72
     */
73 114
    public function setFilesystem(FilesystemInterface $filesystem)
74
    {
75 114
        $this->filesystem = $filesystem;
76
77 114
        return $this;
78
    }
79
    
80
    /**
81
     * Retrieve the Filesystem object.
82
     *
83
     * @return FilesystemInterface
84
     */
85 3
    public function getFilesystem()
86
    {
87 3
        return $this->filesystem;
88
    }
89
90
    /**
91
     * Set the entree path.
92
     *
93
     * @param string $path
94
     *
95
     * @return $this
96
     */
97 75
    public function setPath($path)
98
    {
99 75
        $this->path = $path;
100
101 75
        return $this;
102
    }
103
104
    /**
105
     * Retrieve the entree path.
106
     *
107
     * @return string path
108
     */
109 27
    public function getPath()
110
    {
111 27
        return $this->path;
112
    }
113
114
    /**
115
     * Plugins pass-through.
116
     *
117
     * @param string $method
118
     * @param array  $arguments
119
     *
120
     * @return mixed
121
     */
122 6
    public function __call($method, array $arguments)
123
    {
124 6
        array_unshift($arguments, $this->path);
125 6
        $callback = [$this->filesystem, $method];
126
127
        try {
128 6
            return call_user_func_array($callback, $arguments);
129 3
        } catch (BadMethodCallException $e) {
130 3
            throw new BadMethodCallException(
131
                'Call to undefined method '
132 3
                . get_called_class()
133 3
                . '::' . $method
134
            );
135
        }
136
    }
137
}
138