| Total Complexity | 6 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| 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 | /** @const string Header Content Type */ |
||
| 26 | const HEADER_CONTENT_TYPE = 'application/offset+octet-stream'; |
||
| 27 | |||
| 28 | /** @var Cacheable */ |
||
| 29 | protected $cache; |
||
| 30 | |||
| 31 | /** @var string */ |
||
| 32 | protected $apiPath = '/files'; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Set cache. |
||
| 36 | * |
||
| 37 | * @param mixed $cache |
||
| 38 | * |
||
| 39 | * @throws \ReflectionException |
||
| 40 | * |
||
| 41 | * @return self |
||
| 42 | */ |
||
| 43 | public function setCache($cache) : self |
||
| 44 | { |
||
| 45 | if (is_string($cache)) { |
||
| 46 | $this->cache = CacheFactory::make($cache); |
||
| 47 | } elseif ($cache instanceof Cacheable) { |
||
| 48 | $this->cache = $cache; |
||
| 49 | } |
||
| 50 | |||
| 51 | $prefix = 'tus:' . strtolower((new \ReflectionClass(static::class))->getShortName()) . ':'; |
||
| 52 | |||
| 53 | $this->cache->setPrefix($prefix); |
||
| 54 | |||
| 55 | return $this; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Get cache. |
||
| 60 | * |
||
| 61 | * @return Cacheable |
||
| 62 | */ |
||
| 63 | public function getCache() : Cacheable |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Set API path. |
||
| 70 | * |
||
| 71 | * @param string $path |
||
| 72 | * |
||
| 73 | * @return self |
||
| 74 | */ |
||
| 75 | public function setApiPath(string $path) : self |
||
| 76 | { |
||
| 77 | $this->apiPath = $path; |
||
| 78 | |||
| 79 | return $this; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Get API path. |
||
| 84 | * |
||
| 85 | * @return string |
||
| 86 | */ |
||
| 87 | public function getApiPath() : string |
||
| 90 | } |
||
| 91 | } |
||
| 92 |