1 | <?php |
||
11 | class GithubOAuth |
||
12 | { |
||
13 | const STATE_SESSION_KEY = 'github_state'; |
||
14 | |||
15 | |||
16 | /** @var string */ |
||
17 | protected $clientId; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $secret; |
||
21 | |||
22 | /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface */ |
||
23 | protected $session; |
||
24 | |||
25 | /** @var \BWC\Share\Net\HttpClient\HttpClientInterface */ |
||
26 | protected $httpClient; |
||
27 | |||
28 | |||
29 | |||
30 | /** |
||
31 | * @param string $clientId |
||
32 | * @param string $secret |
||
33 | * @param SessionInterface $session |
||
34 | * @param \BWC\Share\Net\HttpClient\HttpClientInterface $httpClient |
||
35 | */ |
||
36 | public function __construct($clientId, $secret, SessionInterface $session, HttpClientInterface $httpClient) |
||
43 | |||
44 | |||
45 | /** |
||
46 | * @param array $scopes |
||
47 | * @param null|string $redirectUri |
||
48 | * @return RedirectResponse |
||
49 | */ |
||
50 | public function start(array $scopes = null, $redirectUri = null) |
||
69 | |||
70 | /** |
||
71 | * @param string $state |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function isStateValid($state) |
||
88 | |||
89 | /** |
||
90 | * @param string $code |
||
91 | * @throws \Symfony\Component\HttpKernel\Exception\HttpException |
||
92 | * @return GithubAccessResponse |
||
93 | */ |
||
94 | public function getAccessTokenFromCode($code) |
||
126 | |||
127 | } |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: