LocalUrlResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolve() 0 4 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