NoCacheWebPathResolver::resolve()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 17

Duplication

Lines 6
Ratio 35.29 %

Importance

Changes 0
Metric Value
dl 6
loc 17
rs 9.3888
c 0
b 0
f 0
cc 5
nc 4
nop 2
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Imagine\Cache\Resolver;
13
14
use Liip\ImagineBundle\Binary\BinaryInterface;
15
use Liip\ImagineBundle\Imagine\Cache\Helper\PathHelper;
16
use Symfony\Component\Routing\RequestContext;
17
18
class NoCacheWebPathResolver implements ResolverInterface
19
{
20
    /**
21
     * @var RequestContext
22
     */
23
    private $requestContext;
24
25
    public function __construct(RequestContext $requestContext)
26
    {
27
        $this->requestContext = $requestContext;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function isStored($path, $filter)
34
    {
35
        return true;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function resolve($path, $filter)
42
    {
43
        $port = '';
44 View Code Duplication
        if ('https' === $this->requestContext->getScheme() && 443 !== $this->requestContext->getHttpsPort()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
            $port = ":{$this->requestContext->getHttpsPort()}";
46
        }
47 View Code Duplication
        if ('http' === $this->requestContext->getScheme() && 80 !== $this->requestContext->getHttpPort()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
            $port = ":{$this->requestContext->getHttpPort()}";
49
        }
50
51
        return sprintf('%s://%s%s/%s',
52
            $this->requestContext->getScheme(),
53
            $this->requestContext->getHost(),
54
            $port,
55
            ltrim(PathHelper::filePathToUrlPath($path), '/')
56
        );
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function store(BinaryInterface $binary, $path, $filter)
63
    {
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function remove(array $paths, array $filters)
70
    {
71
    }
72
}
73