Passed
Pull Request — master (#407)
by Kirill
05:21
created

File   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 63
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getResolver() 0 3 1
A getPathname() 0 3 1
A __construct() 0 5 1
A __toString() 0 3 1
A getStorage() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Spiral Framework package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Storage;
13
14
use Spiral\Distribution\ResolverInterface;
15
use Spiral\Storage\File\ReadableTrait;
16
use Spiral\Storage\File\UriResolvableTrait;
17
use Spiral\Storage\File\WritableTrait;
18
19
final class File implements FileInterface
20
{
21
    use UriResolvableTrait;
22
    use ReadableTrait;
23
    use WritableTrait;
24
25
    /**
26
     * @var StorageInterface
27
     */
28
    private $storage;
29
30
    /**
31
     * @var string
32
     */
33
    private $pathname;
34
35
    /**
36
     * @var ResolverInterface|null
37
     */
38
    private $resolver;
39
40
    /**
41
     * @param StorageInterface $storage
42
     * @param string $pathname
43
     * @param ResolverInterface|null $resolver
44
     */
45
    public function __construct(StorageInterface $storage, string $pathname, ResolverInterface $resolver = null)
46
    {
47
        $this->storage = $storage;
48
        $this->pathname = $pathname;
49
        $this->resolver = $resolver;
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function __toString(): string
56
    {
57
        return $this->getPathname();
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    public function getPathname(): string
64
    {
65
        return $this->pathname;
66
    }
67
68
    /**
69
     * {@inheritDoc}
70
     */
71
    public function getStorage(): StorageInterface
72
    {
73
        return $this->storage;
74
    }
75
76
    /**
77
     * @return ResolverInterface|null
78
     */
79
    protected function getResolver(): ?ResolverInterface
80
    {
81
        return $this->resolver;
82
    }
83
}
84