Created
July 30, 2020 00:20
-
-
Save ismail1432/de65bb4fb01077824d445a5efdce6aac to your computer and use it in GitHub Desktop.
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\Service; | |
use App\Entity\User; | |
use Symfony\Contracts\HttpClient\HttpClientInterface; | |
class GithubUserRepository | |
{ | |
private $githubClient; | |
public function __construct(HttpClientInterface $githubClient) | |
{ | |
$this->githubClient = $githubClient; | |
} | |
public function findByUsername($username): ?User | |
{ | |
$path = '/users/'.$username; | |
$response = $this->githubClient->request('GET', $path)->toArray(); | |
return User::create($response); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment