Created
August 11, 2023 17:49
-
-
Save mansha99/f5cfe283737d5555bd751dcd86dc1b8b to your computer and use it in GitHub Desktop.
Repository implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Repos; | |
| use App\Contracts\GithubUserRepo; | |
| use Exception; | |
| use Illuminate\Support\Facades\Http; | |
| class GithubUserRepoHttpImpl implements GithubUserRepo | |
| { | |
| public function getUser(string $username) | |
| { | |
| $response = Http::get('https://api.github.com/users/' . $username); | |
| if ($response->status() == 404) { | |
| throw new Exception("User " . $username . " does not exist"); | |
| } | |
| return $response->json(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment