| Conditions | 3 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 32 | public function description(): ?string |
||
| 33 | { |
||
| 34 | $response = Http::withHeaders([ |
||
| 35 | 'Authorization' => 'token '.config('dependencies.github_pat'), |
||
| 36 | ]) |
||
| 37 | ->get($this->api->get()); |
||
| 38 | |||
| 39 | // Client error |
||
| 40 | if ($response->clientError() && str_contains($response->json('message'), 'API rate limit exceeded')) { |
||
| 41 | return null; |
||
| 42 | } |
||
| 43 | |||
| 44 | // Cache response |
||
| 45 | return Cache::remember( |
||
| 46 | config('dependencies.cache.prefix').':api-responses:'.$this->api->get(), |
||
| 47 | config('dependencies.cache.ttl'), |
||
| 48 | function () use ($response) { |
||
| 49 | return $response->json('description'); |
||
| 50 | } |
||
| 54 |