| Total Complexity | 6 |
| Total Lines | 73 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 |
|
| 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 |
|
| 81 | } |
||
| 82 | } |
||
| 83 |