Completed
Push — master ( 223930...766963 )
by Ankit
02:18
created

AbstractTus   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 73
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCache() 0 3 1
A getApiPath() 0 3 1
A setApiPath() 0 5 1
A setCache() 0 9 3
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