| Total Complexity | 5 | 
| Total Lines | 53 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 22 | class SuiteTicket  | 
            ||
| 23 | { | 
            ||
| 24 | use InteractsWithCache;  | 
            ||
| 25 | |||
| 26 | /**  | 
            ||
| 27 | * @var Application  | 
            ||
| 28 | */  | 
            ||
| 29 | protected $app;  | 
            ||
| 30 | |||
| 31 | /**  | 
            ||
| 32 | * SuiteTicket constructor.  | 
            ||
| 33 | * @param Application $app  | 
            ||
| 34 | */  | 
            ||
| 35 | public function __construct(Application $app)  | 
            ||
| 36 |     { | 
            ||
| 37 | $this->app = $app;  | 
            ||
| 38 | }  | 
            ||
| 39 | |||
| 40 | /**  | 
            ||
| 41 | * @param string $ticket  | 
            ||
| 42 | *  | 
            ||
| 43 | * @return $this  | 
            ||
| 44 | *  | 
            ||
| 45 | * @throws \Psr\SimpleCache\InvalidArgumentException  | 
            ||
| 46 | */  | 
            ||
| 47 | public function setTicket(string $ticket)  | 
            ||
| 48 |     { | 
            ||
| 49 | $this->getCache()->set($this->getCacheKey(), $ticket, 600);  | 
            ||
| 50 | |||
| 51 | return $this;  | 
            ||
| 52 | }  | 
            ||
| 53 | |||
| 54 | /**  | 
            ||
| 55 | * @return string  | 
            ||
| 56 | *  | 
            ||
| 57 | * @throws RuntimeException  | 
            ||
| 58 | * @throws \Psr\SimpleCache\InvalidArgumentException  | 
            ||
| 59 | */  | 
            ||
| 60 | public function getTicket(): string  | 
            ||
| 61 |     { | 
            ||
| 62 |         if ($cached = $this->getCache()->get($this->getCacheKey())) { | 
            ||
| 63 | return $cached;  | 
            ||
| 64 | }  | 
            ||
| 65 | |||
| 66 |         throw new RuntimeException('Credential "suite_ticket" does not exist in cache.'); | 
            ||
| 67 | }  | 
            ||
| 68 | |||
| 69 | /**  | 
            ||
| 70 | * @return string  | 
            ||
| 71 | */  | 
            ||
| 72 | protected function getCacheKey(): string  | 
            ||
| 75 | }  | 
            ||
| 76 | }  |