StaticUrlResolver::resolve()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Gaufrette\Extras\Resolvable\Resolver;
4
5
use Gaufrette\Extras\Resolvable\ResolverInterface;
6
7
/**
8
 * Resolves object path by prepending a static prefix.
9
 *
10
 * @author Albin Kerouanton <[email protected]>
11
 */
12
class StaticUrlResolver implements ResolverInterface
13
{
14
    /** @var string */
15
    private $prefix;
16
17
    /**
18
     * @param string $prefix
19
     */
20
    public function __construct($prefix)
21
    {
22
        $this->prefix = rtrim($prefix, '/');
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function resolve($path)
29
    {
30
        return $this->prefix . '/' . ltrim($path, '/');
31
    }
32
}
33