Completed
Push — master ( a06a95...a1d542 )
by dan
15s
created

Url/AwsAdapterUrlEncoder.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This file is part of the IrishDan\ResponsiveImageBundle package.
4
 *
5
 * (c) Daniel Byrne <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE file that was distributed with this source
8
 * code.
9
 */
10
11
namespace IrishDan\ResponsiveImageBundle\Url;
12
13
/**
14
 * Class AwsAdapterUrlEncoder
15
 *
16
 * @package IrishDan\ResponsiveImageBundle\Url
17
 */
18
class AwsAdapterUrlEncoder implements UrlEncoderInterface
19
{
20
    /**
21
     * @param            $adapter
22
     * @param array|null $config
23
     *
24
     * @return mixed|string
25
     */
26
    public function getUrl($adapter, array $config = null)
27
    {
28
        $data = $this->getDataArray($adapter);
29
30
        return 'https://' . 's3-' . $data['region'] . '.amazonaws.com/' . $data['bucket'] . '/' . $data['prefix'] . '/';
31
    }
32
33
    /**
34
     * @param            $data
35
     * @param array|null $config
36
     *
37
     * @return string
38
     */
39
    public function getData($adapter, array $config = null)
40
    {
41
        $data = $this->getDataFromAdapter();
0 ignored issues
show
The method getDataFromAdapter() does not exist on IrishDan\ResponsiveImage...rl\AwsAdapterUrlEncoder. Did you maybe mean getData()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
42
43
        return $data;
44
    }
45
46
    private function getDataArray($adapter)
47
    {
48
        $data = [];
49
50
        $data['prefix'] = $adapter->getPathPrefix();
51
        $data['bucket'] = $adapter->getBucket();
52
        $data['region'] = $adapter->getClient()->getRegion();
53
54
        return $data;
55
    }
56
}