/** * @param GithubService $api * @param $accessResponse */ function processAddEmail(GithubService $api, $accessResponse) { $newEmail = getVariable('email'); $emailCommand = $api->addUserEmails(new Oauth2Token($accessResponse->accessToken), [$newEmail]); $allowedScopes = getAuthorisations(); if (false) { //This isn't working yet. $emailCommand->checkScopeRequirement($allowedScopes); } $emailCommand->execute(); $request = $emailCommand->createRequest(); $request->setBody(json_encode([$newEmail])); $response = $emailCommand->dispatch($request); }