FortrabbitAdapter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 63
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getStorageUrl() 0 4 1
A setStorageUrl() 0 12 3
A getUrl() 0 4 1
1
<?php
2
3
namespace Nedmas\FortrabbitStorage\Filesystem;
4
5
use Aws\S3\S3Client;
6
use League\Flysystem\AwsS3v3\AwsS3Adapter;
7
8
class FortrabbitAdapter extends AwsS3Adapter
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $storageUrl;
14
15
    /**
16
     * Constructor.
17
     *
18
     * @param S3Client $client
19
     * @param string   $bucket
20
     * @param string   $prefix
21
     * @param array    $options
22
     * @param string   $storageUrl
23
     */
24 12
    public function __construct(S3Client $client, $bucket, $prefix = '', array $options = [], $storageUrl = '')
25
    {
26 12
        parent::__construct($client, $bucket, $prefix, $options);
27
28 12
        $this->setStorageUrl($storageUrl);
29 12
    }
30
31
    /**
32
     * Get the storage URL.
33
     *
34
     * @return string storage URL
35
     */
36 6
    public function getStorageUrl()
37
    {
38 6
        return $this->storageUrl;
39
    }
40
41
    /**
42
     * Set the storage URL.
43
     *
44
     * @param string $url
45
     *
46
     * @return self
47
     */
48 12
    public function setStorageUrl($url)
49
    {
50 12
        $is_empty = empty($url);
51
52 12
        if (!$is_empty) {
53 12
            $url = rtrim($url, $this->pathSeparator) . $this->pathSeparator;
54 8
        }
55
56 12
        $this->storageUrl = $is_empty ? null : $url;
57
58 12
        return $this;
59
    }
60
61
    /**
62
     * Get the public URL.
63
     *
64
     * @return string public URL
65
     */
66 6
    public function getUrl($path)
67
    {
68 6
        return $this->storageUrl . $this->pathPrefix . $path;
69
    }
70
}
71