AwsS3Resolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getObjectPath() 0 9 2
1
<?php
2
3
namespace Jb\Bundle\FileUploaderBundle\Service\Imagine;
4
5
use Aws\S3\S3Client;
6
use Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver as BaseAwsS3Resolver;
7
8
class AwsS3Resolver extends BaseAwsS3Resolver
9
{
10
    /**
11
     * Constructs a cache resolver storing images on Amazon S3.
12
     *
13
     * @param S3Client $storage The Amazon S3 storage API. It's required to know authentication information.
14
     * @param string $bucket The bucket name to operate on.
15
     * @param string $acl The ACL to use when storing new objects. Default: owner read/write, public read
16
     * @param array $objUrlOptions A list of options to be passed when retrieving the object url from Amazon S3.
17
     */
18
    public function __construct(S3Client $storage, $bucket, $acl = "public-read", array $objUrlOptions = array())
19
    {
20
        $this->storage = $storage;
21
        $this->bucket = $bucket;
22
        $this->acl = $acl;
23
        $this->objUrlOptions = $objUrlOptions;
0 ignored issues
show
Bug introduced by
The property objUrlOptions does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
    }
25
26
    /**
27
     * Returns the object path within the bucket.
28
     *
29
     * @param string $path The base path of the resource.
30
     * @param string $filter The name of the imagine filter in effect.
31
     *
32
     * @return string The path of the object on S3.
33
     */
34
    protected function getObjectPath($path, $filter)
35
    {
36
        // If original in aws3, then it is in the images folder
37
        if ($filter == 'original') {
38
            return $path;
39
        }
40
41
        return parent::getObjectPath($path, $filter);
42
    }
43
}
44