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

File::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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