PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
wpide / vendor / league / flysystem / src / Handler.php

Handler.php in WPIDE – File Manager & Code Editor 3.5.9, at vendor/league/flysystem/src/Handler.php

138 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 public function __construct(FilesystemInterface $filesystem = null, $path = null)
29 {
30 $this->path = $path;
31 $this->filesystem = $filesystem;
32 }
33
34 /**
35 * Check whether the entree is a directory.
36 *
37 * @return bool
38 */
39 public function isDir()
40 {
41 return $this->getType() === 'dir';
42 }
43
44 /**
45 * Check whether the entree is a file.
46 *
47 * @return bool
48 */
49 public function isFile()
50 {
51 return $this->getType() === 'file';
52 }
53
54 /**
55 * Retrieve the entree type (file|dir).
56 *
57 * @return string file or dir
58 */
59 public function getType()
60 {
61 $metadata = $this->filesystem->getMetadata($this->path);
62
63 return $metadata ? $metadata['type'] : 'dir';
64 }
65
66 /**
67 * Set the Filesystem object.
68 *
69 * @param FilesystemInterface $filesystem
70 *
71 * @return $this
72 */
73 public function setFilesystem(FilesystemInterface $filesystem)
74 {
75 $this->filesystem = $filesystem;
76
77 return $this;
78 }
79
80 /**
81 * Retrieve the Filesystem object.
82 *
83 * @return FilesystemInterface
84 */
85 public function getFilesystem()
86 {
87 return $this->filesystem;
88 }
89
90 /**
91 * Set the entree path.
92 *
93 * @param string $path
94 *
95 * @return $this
96 */
97 public function setPath($path)
98 {
99 $this->path = $path;
100
101 return $this;
102 }
103
104 /**
105 * Retrieve the entree path.
106 *
107 * @return string path
108 */
109 public function getPath()
110 {
111 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 public function __call($method, array $arguments)
123 {
124 array_unshift($arguments, $this->path);
125 $callback = [$this->filesystem, $method];
126
127 try {
128 return call_user_func_array($callback, $arguments);
129 } catch (BadMethodCallException $e) {
130 throw new BadMethodCallException(
131 'Call to undefined method '
132 . get_called_class()
133 . '::' . $method
134 );
135 }
136 }
137 }
138