Completed
Pull Request — master (#71)
by Ankit
02:02
created

AbstractTus::setApiPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
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
    public function setCache($cache) : self
39
    {
40
        if (is_string($cache)) {
41
            $this->cache = CacheFactory::make($cache);
42
        } elseif ($cache instanceof Cacheable) {
43
            $this->cache = $cache;
44
        }
45
46
        return $this;
47
    }
48
49
    /**
50
     * Get cache.
51
     *
52
     * @return Cacheable
53
     */
54
    public function getCache() : Cacheable
55
    {
56
        return $this->cache;
57
    }
58
59
    /**
60
     * Set API path.
61
     *
62
     * @param string $path
63
     *
64
     * @return self
65
     */
66
    public function setApiPath(string $path) : self
67
    {
68
        $this->apiPath = $path;
69
70
        return $this;
71
    }
72
73
    /**
74
     * Get API path.
75
     *
76
     * @return string
77
     */
78
    public function getApiPath() : string
79
    {
80
        return $this->apiPath;
81
    }
82
}
83