Completed
Push — master ( 766963...aceb5e )
by Ankit
02:21
created

AbstractTus::setCache()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace TusPhp\Tus;
4
5
use TusPhp\Cache\Cacheable;
6
use TusPhp\Cache\CacheFactory;
7
8
abstract class AbstractTus
9
{
10
    /** @const string Tus protocol version. */
11
    const TUS_PROTOCOL_VERSION = '1.0.0';
12
13
    /** @const string Name separator for partial upload. */
14
    const PARTIAL_UPLOAD_NAME_SEPARATOR = '_';
15
16
    /** @const string Upload type normal. */
17
    const UPLOAD_TYPE_NORMAL = 'normal';
18
19
    /** @const string Upload type partial. */
20
    const UPLOAD_TYPE_PARTIAL = 'partial';
21
22
    /** @const string Upload type final. */
23
    const UPLOAD_TYPE_FINAL = 'final';
24
25
    /** @var Cacheable */
26
    protected $cache;
27
28
    /** @var string */
29
    protected $apiPath = '/files';
30
31
    /**
32
     * Set cache.
33
     *
34
     * @param mixed $cache
35
     *
36
     * @return self
37
     */
38 1
    public function setCache($cache) : self
39
    {
40 1
        if (is_string($cache)) {
41 1
            $this->cache = CacheFactory::make($cache);
42 1
        } elseif ($cache instanceof Cacheable) {
43 1
            $this->cache = $cache;
44
        }
45
46 1
        return $this;
47
    }
48
49
    /**
50
     * Get cache.
51
     *
52
     * @return Cacheable
53
     */
54 1
    public function getCache() : Cacheable
55
    {
56 1
        return $this->cache;
57
    }
58
59
    /**
60
     * Set API path.
61
     *
62
     * @param string $path
63
     *
64
     * @return self
65
     */
66 1
    public function setApiPath(string $path) : self
67
    {
68 1
        $this->apiPath = $path;
69
70 1
        return $this;
71
    }
72
73
    /**
74
     * Get API path.
75
     *
76
     * @return string
77
     */
78 1
    public function getApiPath() : string
79
    {
80 1
        return $this->apiPath;
81
    }
82
}
83