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 / Plugin / GetWithMetadata.php

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

52 lines 1.2 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\Plugin;
4
5 use InvalidArgumentException;
6 use League\Flysystem\FileNotFoundException;
7
8 class GetWithMetadata extends AbstractPlugin
9 {
10 /**
11 * Get the method name.
12 *
13 * @return string
14 */
15 public function getMethod()
16 {
17 return 'getWithMetadata';
18 }
19
20 /**
21 * Get metadata for an object with required metadata.
22 *
23 * @param string $path path to file
24 * @param string[] $metadata metadata keys
25 *
26 * @throws InvalidArgumentException
27 * @throws FileNotFoundException
28 *
29 * @return array|false metadata
30 */
31 public function handle($path, array $metadata)
32 {
33 $object = $this->filesystem->getMetadata($path);
34
35 if ( ! $object) {
36 return false;
37 }
38
39 $keys = array_diff($metadata, array_keys($object));
40
41 foreach ($keys as $key) {
42 if ( ! method_exists($this->filesystem, $method = 'get' . ucfirst($key))) {
43 throw new InvalidArgumentException('Could not fetch metadata: ' . $key);
44 }
45
46 $object[$key] = $this->filesystem->{$method}($path);
47 }
48
49 return $object;
50 }
51 }
52