| Conditions | 4 |
| Paths | 6 |
| Total Lines | 31 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public function handle(): int |
||
| 23 | { |
||
| 24 | if (! $this->confirmToProceed()) { |
||
| 25 | return self::FAILURE; |
||
| 26 | } |
||
| 27 | |||
| 28 | $this->line('<options=bold>Client App Credentials</>'); |
||
| 29 | |||
| 30 | $this->writeConfig('client_id'); |
||
| 31 | |||
| 32 | $this->writeConfig('client_secret'); |
||
| 33 | |||
| 34 | try { |
||
| 35 | $apiRes = Authorization::getToken(); |
||
| 36 | |||
| 37 | $this->line(json_encode($apiRes, JSON_PRETTY_PRINT)); |
||
| 38 | } catch (RequestException $ex) { |
||
| 39 | $response = $ex->getResponse(); |
||
| 40 | |||
| 41 | if ($response instanceof ResponseInterface) { |
||
| 42 | $this->error($response->getStatusCode().' '.$response->getReasonPhrase()); |
||
| 43 | |||
| 44 | $this->error($response->getBody()); |
||
| 45 | |||
| 46 | return self::FAILURE; |
||
| 47 | } |
||
| 48 | |||
| 49 | $this->error($ex->getMessage()); |
||
| 50 | } |
||
| 51 | |||
| 52 | return self::SUCCESS; |
||
| 53 | } |
||
| 55 |