当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getHttpClient方法代码示例

本文整理汇总了PHP中Github\Client::getHttpClient方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getHttpClient方法的具体用法?PHP Client::getHttpClient怎么用?PHP Client::getHttpClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Github\Client的用法示例。


在下文中一共展示了Client::getHttpClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build

 public function build($username, $repository)
 {
     $this->repository = new Repository($username, $repository);
     // repository data
     $data = $this->client->api('repo')->show($this->repository->username, $this->repository->repository);
     $this->repository->size = $data['size'];
     $this->repository->stargazersCount = $data['stargazers_count'];
     $this->repository->forks = $data['forks'];
     $this->repository->openIssues = $data['open_issues'];
     $this->repository->subscribersCount = $data['subscribers_count'];
     // repository commit activity
     do {
         $activity = $this->client->api('repo')->activity($this->repository->username, $this->repository->repository);
         $responseStatusCode = $this->client->getHttpClient()->getLastResponse()->getStatusCode();
         if ($responseStatusCode != 200) {
             sleep(3);
         } else {
             break;
         }
     } while (true);
     $commitsLastYear = array_map(function (array $weekCommits) {
         return $weekCommits['total'];
     }, $activity);
     $this->repository->commitsCount = array_sum($commitsLastYear);
     $this->repository->commitsLastMonthCount = array_sum(array_slice($commitsLastYear, -4));
     $this->repository->avgCommitsPerWeek = count($commitsLastYear) > 0 ? floor(array_sum($commitsLastYear) / count($commitsLastYear)) : 0;
     // repository contributors
     $paginator = new ResultPager($this->client);
     $contributors = $paginator->fetchAll($this->client->api('repo'), 'contributors', [$this->repository->username, $this->repository->repository, true]);
     $this->repository->contributorsCount = count($contributors);
     // user data
     $user = $this->client->api('user')->show($this->repository->username);
     $this->repository->userPublicRepos = $user['public_repos'];
     return $this;
 }
开发者ID:ostretsov,项目名称:githubcmp,代码行数:35,代码来源:GithubRepositoryBuilder.php

示例2: setHttpClient

 /**
  * @param  Client           $githubClient
  * @return GithubRepository
  */
 public function setHttpClient(Client $githubClient)
 {
     $this->githubClient = $githubClient;
     // see https://developer.github.com/changes/2015-04-17-preview-repository-redirects/
     $this->githubClient->getHttpClient()->setHeaders(array('Accept' => 'application/vnd.github.quicksilver-preview+json'));
     return $this;
 }
开发者ID:iamduyu,项目名称:bowerphp,代码行数:11,代码来源:GithubRepository.php

示例3: updateVersionsHistory

 public function updateVersionsHistory(Bundle $bundle)
 {
     // no composer file
     if (null === ($composerName = $bundle->getComposerName())) {
         return false;
     }
     // query packagist json
     $packagistArray = $this->github->getHttpClient()->get($composerName, array(), array('url' => 'http://packagist.org/packages/:path.json'));
     // if json not encoded
     if (!is_array($packagistArray) || !isset($packagistArray['package'])) {
         return false;
     }
     $versionsHistory = array();
     $versionsArray = $packagistArray['package']['versions'];
     foreach ($versionsArray as $version => $value) {
         // Skip `dev` packages, add only `dev-master`
         if (0 === strpos($version, 'dev-') && 'dev-master' != $version) {
             continue;
         }
         foreach (array('symfony/framework-bundle', 'symfony/symfony') as $requirement) {
             if (isset($value['require'][$requirement])) {
                 $versionsHistory['symfony'][$version] = $value['require'][$requirement];
                 // array('master' => '>=2.0,<2.2-dev')
             }
         }
         // store all bundle dependencies
         $versionsHistory['dependencies'][$version] = array('name' => $value['name'], 'extra' => isset($value['extra']) ? $value['require-dev'] : '', 'require' => $value['require'], 'require-dev' => isset($value['require-dev']) ? $value['require-dev'] : '', 'suggest' => isset($value['suggest']) ? $value['suggest'] : '');
     }
     if (!empty($versionsHistory)) {
         $bundle->setVersionsHistory($versionsHistory);
     }
     return true;
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:33,代码来源:Repo.php

示例4: getContents

 /**
  * Temporary workaround of the GitHub client bug
  *
  * @param string $sha
  * @return string
  */
 protected function getContents($sha)
 {
     $path = 'repos/' . rawurlencode($this->user) . '/' . rawurlencode($this->repo) . '/git/blobs/' . rawurlencode($sha);
     $response = $this->client->getHttpClient()->get($path);
     $contents = $response->getBody(true);
     return $contents;
 }
开发者ID:morozov,项目名称:diff-sniffer-pull-request,代码行数:13,代码来源:PullRequest.php

示例5: register

 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     $app['github'] = $app->share(function () {
         $client = new Client(new CachedHttpClient(['cache_dir' => __DIR__ . '/../../../app/cache/github-api-cache']));
         return new GithubAdapter($client->getHttpClient());
     });
 }
开发者ID:CipHuK,项目名称:phansible,代码行数:10,代码来源:GithubProvider.php

示例6: get

 /**
  * {@inheritdoc}
  */
 protected function get($key)
 {
     if ($this->has($key)) {
         $result = $this->client->getHttpClient()->get($this->pagination[$key]);
         $this->postFetch();
         return ResponseMediator::getContent($result);
     }
 }
开发者ID:SethMcGathey,项目名称:html,代码行数:11,代码来源:ResultPager.php

示例7: updateRemoteStatus

 /**
  * Update webhooks for repo
  *
  * @param $repo
  * @param $secret
  */
 private function updateRemoteStatus($repo, $secret)
 {
     foreach (['issues', 'issue_comment'] as $event) {
         $action = $repo->isUsed() ? 'subscribe' : 'unsubscribe';
         $topic = 'https://github.com/' . $repo->getFullname() . '/events/' . $event;
         $this->client->getHttpClient()->post('/hub', ['hub.mode' => $action, 'hub.topic' => $topic, 'hub.callback' => UrlHelper::getHost() . '/github/fromissue', 'hub.secret' => $secret]);
     }
 }
开发者ID:eliberty,项目名称:octocoupler,代码行数:14,代码来源:SetupController.php

示例8: logHttp

 /**
  * Debug HTTP interactions
  *
  * @param Client          $client
  * @param OutputInterface $output
  */
 protected function logHttp(Client $client, OutputInterface $output)
 {
     $guzzle = $client->getHttpClient();
     if (OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity()) {
         $logger = function ($message) use($output) {
             $finfo = new \finfo(FILEINFO_MIME);
             $msg = substr($finfo->buffer($message), 0, 4) == 'text' ? $message : '(binary string)';
             $output->writeln('<info>Guzzle</info> ' . $msg);
         };
         $logAdapter = new ClosureLogAdapter($logger);
         $logPlugin = new LogPlugin($logAdapter, MessageFormatter::DEBUG_FORMAT);
         $guzzle->addSubscriber($logPlugin);
     }
 }
开发者ID:iamduyu,项目名称:bowerphp,代码行数:20,代码来源:Command.php

示例9: buildGitHubClient

 /**
  * @return Client
  */
 protected function buildGitHubClient()
 {
     $httpClient = new HttpClient(['base_url' => $this->config['base_url']]);
     $client = new Client($httpClient);
     if (false !== getenv('GITHUB_DEBUG')) {
         $logPlugin = LogPlugin::getDebugPlugin();
         $httpClient = $client->getHttpClient();
         $httpClient->addSubscriber($logPlugin);
     }
     $client->setOption('base_url', $this->config['base_url']);
     $this->url = rtrim($this->config['base_url'], '/');
     $this->domain = rtrim($this->config['repo_domain_url'], '/');
     return $client;
 }
开发者ID:gushphp,项目名称:gush,代码行数:17,代码来源:GitHubAdapter.php

示例10: it_returns_Issue_objects_on_getIssues

 public function it_returns_Issue_objects_on_getIssues(Client $client, Issue $api, HttpClient $http, Response $response)
 {
     $client->issue()->willReturn($api);
     $client->getHttpClient()->willReturn($http);
     $api->getPerPage()->willReturn(5);
     $api->setPerPage(Argument::any())->willReturn();
     $http->getLastResponse()->willReturn($response);
     $response->getHeader('Link')->willReturn(null);
     $api->all('foo', 'bar', ['state' => 'open'])->willReturn([['number' => 1], ['number' => 5]]);
     $result = $this->getIssues();
     $result->shouldBeArray();
     $result->shouldHaveCount(2);
     $result[0]->shouldHaveType('Rs\\Issues\\Github\\GithubIssue');
     $result[0]->getId()->shouldBe(1);
     $result[1]->shouldHaveType('Rs\\Issues\\Github\\GithubIssue');
     $result[1]->getId()->shouldBe(5);
 }
开发者ID:digitalkaoz,项目名称:issues,代码行数:17,代码来源:GithubProjectSpec.php

示例11: testInstanciateWithHttpClient

 public function testInstanciateWithHttpClient()
 {
     $httpClient = $this->getHttpClientMock();
     $client = new Client($httpClient);
     $this->assertEquals($httpClient, $client->getHttpClient());
 }
开发者ID:nickl-,项目名称:php-github-api,代码行数:6,代码来源:ClientTest.php

示例12: shouldSetHeadersLaizly

 /**
  * @test
  */
 public function shouldSetHeadersLaizly()
 {
     $client = new Client();
     $client->setHeaders(array('header1', 'header2'));
     $this->assertInstanceOf('Github\\HttpClient\\HttpClientInterface', $client->getHttpClient());
 }
开发者ID:nschappl,项目名称:software_engineering,代码行数:9,代码来源:ClientTest.php

示例13: postGistComment

 /**
  * @param $gistId
  * @param $comment
  * @return array
  */
 public function postGistComment($gistId, $comment)
 {
     $this->github->authenticate(Auth::user()->token, GitHubClient::AUTH_HTTP_TOKEN);
     $response = $this->github->getHttpClient()->post("gists/{$gistId}/comments", json_encode(['body' => $comment]));
     return ResponseMediator::getContent($response);
 }
开发者ID:thomasbabuj,项目名称:gistlog,代码行数:11,代码来源:GistClient.php

示例14: getRawActivities

 private function getRawActivities($limit = 5)
 {
     $response = $this->client->getHttpClient()->get("users/{$this->user}/events");
     $activities = ResponseMediator::getContent($response);
     return array_slice($activities, 0, $limit);
 }
开发者ID:nWidart,项目名称:activity,代码行数:6,代码来源:Activity.php

示例15: shouldPassHttpClientInterfaceToConstructor

 /**
  * @test
  */
 public function shouldPassHttpClientInterfaceToConstructor()
 {
     $client = new Client($this->getHttpClientMock());
     $this->assertInstanceOf('Github\\HttpClient\\HttpClientInterface', $client->getHttpClient());
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:8,代码来源:ClientTest.php


注:本文中的Github\Client::getHttpClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。