Skip to content

Instantly share code, notes, and snippets.

@ismail1432
Created July 30, 2020 00:20
Show Gist options
  • Save ismail1432/de65bb4fb01077824d445a5efdce6aac to your computer and use it in GitHub Desktop.
Save ismail1432/de65bb4fb01077824d445a5efdce6aac to your computer and use it in GitHub Desktop.
<?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