LocalUrlResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SfCod\Filesystem\Resolvable\Resolver;
4
5
use SfCod\Filesystem\Resolvable\ResolverInterface;
6
7
/**
8
 * Class LocalUrlResolver
9
 *
10
 * @author Virchenko Maksim <[email protected]>
11
 *
12
 * @package SfCod\Filesystem\Resolvable\Resolver
13
 */
14
class LocalUrlResolver implements ResolverInterface
15
{
16
    /**
17
     * Path prefix
18
     *
19
     * @var string
20
     */
21
    private $prefix;
22
23
    /**
24
     * LocalUrlResolver constructor.
25
     *
26
     * @param string $prefix
27
     */
28
    public function __construct(string $prefix = '/storage')
29
    {
30
        $this->prefix = $prefix;
31
    }
32
33
    /**
34
     * Resolves an object path to an URI.
35
     *
36
     * @param string $path Object path
37
     *
38
     * @return string
39
     */
40
    public function resolve(string $path): string
41
    {
42
        return rtrim($this->prefix, '/') . '/' . ltrim($path, '/');
43
    }
44
}
45