Test Failed
Push — master ( e493d7...b1ea68 )
by Petr
11:01
created

FinalStorage::exists()   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 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace kalanis\UploadPerPartes\Target\Local\FinalStorage;
4
5
6
use kalanis\UploadPerPartes\Interfaces\IFinalStorage;
7
use kalanis\UploadPerPartes\Uploader\Data;
8
use kalanis\UploadPerPartes\UploadException;
9
10
11
/**
12
 * Class FinalStorage
13
 * @package kalanis\UploadPerPartes\Target\Local\FinalStorage
14
 * Actions over final storage
15
 */
16
class FinalStorage
17
{
18
    protected IFinalStorage $storage;
19
    protected KeyEncoders\AEncoder $keyEncoder;
20
21
    public function __construct(
22
        IFinalStorage $storage,
23
        KeyEncoders\AEncoder $keyEncoder
24
    )
25
    {
26
        $this->storage = $storage;
27
        $this->keyEncoder = $keyEncoder;
28
    }
29
30
    /**
31
     * @param Data $data
32
     * @throws UploadException
33
     * @return bool
34
     */
35
    public function exists(Data $data): bool
36
    {
37
        return $this->storage->exists($this->keyEncoder->toPath($data));
38
    }
39
40
    /**
41
     * @param string $key
42
     * @param resource $source
43
     * @throws UploadException
44
     * @return bool
45
     */
46
    public function store(string $key, $source): bool
47
    {
48
        return $this->storage->store($key, $source);
49
    }
50
51
    /**
52
     * @param Data $data
53
     * @throws UploadException
54
     * @return string
55
     */
56
    public function findName(Data $data): string
57
    {
58
        return $this->storage->findName($this->keyEncoder->toPath($data));
59
    }
60
}
61