Passed
Pull Request — master (#42)
by
unknown
08:12 queued 05:35
created

Flysystem::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace AnyCloud\File\Store;
4
5
use League\Flysystem\Filesystem;
6
use League\Flysystem\Visibility;
7
use Omeka\File\Store\StoreInterface;
8
9
class Flysystem implements StoreInterface
10
{
11
    protected $filesystem;
12
13
    public function __construct(Filesystem $filesystem)
14
    {
15
        $this->filesystem = $filesystem;
16
    }
17
18
    public function put($source, $storagePath)
19
    {
20
        $fh = fopen($source, 'r');
21
        if ($fh === false) {
22
            throw new \Omeka\File\Exception\RuntimeException(sprintf('Failed to open "%s"', $source));
0 ignored issues
show
Bug introduced by
The type Omeka\File\Exception\RuntimeException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
        }
24
25
        $config = ['visibility' => Visibility::PUBLIC];
26
        $this->filesystem->writeStream($storagePath, $fh, $config);
27
        fclose($fh);
28
    }
29
30
    public function delete($storagePath)
31
    {
32
        $this->filesystem->delete($storagePath);
33
    }
34
35
    public function getUri($storagePath)
36
    {
37
        return $this->filesystem->publicUrl($storagePath);
38
    }
39
}
40