Completed
Push — master ( e1aae9...7bc8ae )
by
unknown
96:15 queued 73:35
created

ProxyResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A rewriteUrl() 0 11 2
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Bundle\EzPublishCoreBundle\Imagine\Cache\Resolver;
8
9
use Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver as ImagineProxyResolver;
10
11
class ProxyResolver extends ImagineProxyResolver
12
{
13
    /**
14
     * Replaces host with given proxy host.
15
     *
16
     * The original method from Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver:rewriteUrl()
17
     * doesn't behave correctly when working with domain and port or with host which contains trailing slash.
18
     *
19
     * @param string $url
20
     * @return string
21
     */
22
    protected function rewriteUrl($url)
23
    {
24
        if (empty($this->hosts)) {
25
            return $url;
26
        }
27
28
        $proxyHost = rtrim(reset($this->hosts), '/');
29
        $relativeUrl = parse_url($url, PHP_URL_PATH);
30
31
        return $proxyHost . $relativeUrl;
32
    }
33
}
34