Passed
Push — master ( 865ea9...f5a1ef )
by butschster
29:08 queued 21:20
created

ReadableTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 9
dl 0
loc 55
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getVisibility() 0 4 1
A getStream() 0 3 1
A getContents() 0 3 1
A getLastModified() 0 3 1
A exists() 0 3 1
A getMimeType() 0 3 1
A getSize() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Storage\File;
6
7
use JetBrains\PhpStorm\ExpectedValues;
8
use Spiral\Storage\BucketInterface;
9
use Spiral\Storage\Visibility;
10
11
/**
12
 * @mixin ReadableInterface
13
 */
14
trait ReadableTrait
15
{
16
    /**
17
     * {@see EntryInterface::getPathname()}
18
     */
19
    abstract public function getPathname(): string;
20
21
    /**
22
     * {@see EntryInterface::getBucket()}
23
     */
24
    abstract public function getBucket(): BucketInterface;
25
26
    public function exists(): bool
27
    {
28
        return $this->getBucket()->exists($this->getPathname());
29
    }
30
31
    public function getContents(): string
32
    {
33
        return $this->getBucket()->getContents($this->getPathname());
34
    }
35
36
    public function getStream()
37
    {
38
        return $this->getBucket()->getStream($this->getPathname());
39
    }
40
41
    /**
42
     * @return positive-int
0 ignored issues
show
Documentation Bug introduced by
The doc comment positive-int at position 0 could not be parsed: Unknown type name 'positive-int' at position 0 in positive-int.
Loading history...
43
     */
44
    public function getLastModified(): int
45
    {
46
        return $this->getBucket()->getLastModified($this->getPathname());
47
    }
48
49
    /**
50
     * @return positive-int|0
0 ignored issues
show
Documentation Bug introduced by
The doc comment positive-int|0 at position 0 could not be parsed: Unknown type name 'positive-int' at position 0 in positive-int|0.
Loading history...
51
     */
52
    public function getSize(): int
53
    {
54
        return $this->getBucket()->getSize($this->getPathname());
55
    }
56
57
    public function getMimeType(): string
58
    {
59
        return $this->getBucket()->getMimeType($this->getPathname());
60
    }
61
62
    /**
63
     * @return Visibility::VISIBILITY_*
64
     */
65
    #[ExpectedValues(valuesFromClass: Visibility::class)]
66
    public function getVisibility(): string
67
    {
68
        return $this->getBucket()->getVisibility($this->getPathname());
69
    }
70
}
71