forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple from Guzzle by using HTTPlug
- Loading branch information
Showing
48 changed files
with
1,001 additions
and
1,882 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
preset: psr2 | ||
|
||
enabled: | ||
- long_array_syntax | ||
- return |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Github\Api; | ||
|
||
/** | ||
* A trait to make sure we add accept headers on all requests. | ||
* | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
trait AcceptHeaderTrait | ||
{ | ||
protected $acceptHeaderValue = null; | ||
|
||
protected function get($path, array $parameters = array(), $requestHeaders = array()) | ||
{ | ||
return parent::get($path, $parameters, $this->mergeHeaders($requestHeaders)); | ||
} | ||
|
||
protected function head($path, array $parameters = array(), $requestHeaders = array()) | ||
{ | ||
return parent::head($path, $parameters, $this->mergeHeaders($requestHeaders)); | ||
} | ||
|
||
protected function post($path, array $parameters = array(), $requestHeaders = array()) | ||
{ | ||
return parent::post($path, $parameters, $this->mergeHeaders($requestHeaders)); | ||
} | ||
|
||
protected function postRaw($path, $body, $requestHeaders = array()) | ||
{ | ||
return parent::postRaw($path, $body, $this->mergeHeaders($requestHeaders)); | ||
} | ||
|
||
protected function patch($path, array $parameters = array(), $requestHeaders = array()) | ||
{ | ||
return parent::patch($path, $parameters, $this->mergeHeaders($requestHeaders)); | ||
} | ||
|
||
protected function put($path, array $parameters = array(), $requestHeaders = array()) | ||
{ | ||
return parent::put($path, $parameters, $this->mergeHeaders($requestHeaders)); | ||
} | ||
|
||
protected function delete($path, array $parameters = array(), $requestHeaders = array()) | ||
{ | ||
return parent::delete($path, $parameters, $this->mergeHeaders($requestHeaders)); | ||
} | ||
|
||
/** | ||
* Append a new accept header on all requests | ||
* @return array | ||
*/ | ||
private function mergeHeaders(array $headers = array()) | ||
{ | ||
$default = array(); | ||
if ($this->acceptHeaderValue) { | ||
$default = array('Accept' => $this->acceptHeaderValue); | ||
} | ||
|
||
return array_merge($default, $headers); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,27 @@ | |
namespace Github\Api\GitData; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Api\AcceptHeaderTrait; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
/** | ||
* @link http://developer.github.com/v3/git/blobs/ | ||
* @author Joseph Bielawski <[email protected]> | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
class Blobs extends AbstractApi | ||
{ | ||
use AcceptHeaderTrait; | ||
|
||
/** | ||
* Configure the Acccept header depending on the blob type. | ||
* | ||
* @param string|null $bodyType | ||
*/ | ||
public function configure($bodyType = null) | ||
{ | ||
if ('raw' == $bodyType) { | ||
$this->client->setHeaders(array( | ||
'Accept' => sprintf('application/vnd.github.%s.raw', $this->client->getOption('api_version')) | ||
)); | ||
if ('raw' === $bodyType) { | ||
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.raw', $this->client->getOption('api_version')); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.