Skip to content

Commit

Permalink
Resolves issue #34
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Dec 5, 2020
1 parent 30455a4 commit 65a5fa4
Show file tree
Hide file tree
Showing 20 changed files with 113 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ before_script:
- composer install --prefer-dist --no-interaction -o

script:
- ./vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover
- XDEBUG_MODE=coverage ./vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover
- if [ "$CS_FIXER" = "run" ]; then php vendor/bin/php-cs-fixer fix --verbose --dry-run ; fi;

after_script:
Expand Down
3 changes: 0 additions & 3 deletions lib/Imgur/Api/Album.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public function favoriteAlbum($albumId)
* (Not available for anonymous albums.).
*
* @param string $albumId
* @param array $imageIds
*
* @see https://api.imgur.com/endpoints/album#album-set-to
*
Expand All @@ -138,7 +137,6 @@ public function setAlbumImages($albumId, array $imageIds)
* (Not available for anonymous albums. Adding images to an anonymous album is only available during image uploading.).
*
* @param string $albumId
* @param array $imageIds
*
* @see https://api.imgur.com/endpoints/album#album-add-to
*
Expand All @@ -154,7 +152,6 @@ public function addImages($albumId, array $imageIds)
* For anonymous albums, $deletehashOrAlbumId should be the deletehash that is returned at creation.
*
* @param string $deletehashOrAlbumId
* @param array $imageIds
*
* @see https://api.imgur.com/endpoints/album#album-remove-from
*
Expand Down
4 changes: 0 additions & 4 deletions lib/Imgur/Api/CustomGallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public function image($imageId)
/**
* Add tags to a user's custom gallery.
*
* @param array $tags
*
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-add
*
* @return bool
Expand All @@ -78,8 +76,6 @@ public function addTags(array $tags)
/**
* Remove tags from a custom gallery.
*
* @param array $tags
*
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-remove
*
* @return bool
Expand Down
2 changes: 1 addition & 1 deletion lib/Imgur/Api/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function upload($data)
}

if ('file' === $data['type']) {
$data['image'] = '@' . $data['image'];
$data['image'] = fopen($data['image'], 'r');
}

return $this->post('image', $data);
Expand Down
5 changes: 2 additions & 3 deletions lib/Imgur/Auth/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ class OAuth2 implements AuthInterface
/**
* Instantiates the OAuth2 class, but does not trigger the authentication process.
*
* @param HttpClientInterface $httpClient
* @param string $clientId
* @param string $clientSecret
* @param string $clientId
* @param string $clientSecret
*/
public function __construct(HttpClientInterface $httpClient, $clientId, $clientSecret)
{
Expand Down
3 changes: 0 additions & 3 deletions lib/Imgur/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ public function getHttpClient()
return $this->httpClient;
}

/**
* @param HttpClientInterface $httpClient
*/
public function setHttpClient(HttpClientInterface $httpClient)
{
$this->httpClient = $httpClient;
Expand Down
16 changes: 14 additions & 2 deletions lib/Imgur/HttpClient/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class HttpClient implements HttpClientInterface
protected $stack;

/**
* @param array $options
* @param ClientInterface $client
*/
public function __construct(array $options = [], ClientInterface $client = null)
Expand Down Expand Up @@ -108,7 +107,20 @@ public function performRequest($url, $parameters, $httpMethod = 'GET')
}

if ('POST' === $httpMethod || 'PUT' === $httpMethod || 'DELETE' === $httpMethod) {
$options['form_params'] = $parameters;
if ('POST' === $httpMethod && isset($parameters['type']) && 'file' === $parameters['type']) {
$options['multipart'] = [
[
'name' => 'type',
'contents' => $parameters['type'],
],
[
'name' => 'image',
'contents' => $parameters['image'],
],
];
} else {
$options['form_params'] = $parameters;
}
}

// will throw an Imgur\Exception\ExceptionInterface if sth goes wrong
Expand Down
2 changes: 0 additions & 2 deletions lib/Imgur/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public function __construct($token, $clientId)

/**
* Add Authorization header to the request.
*
* @param RequestInterface $request
*/
public function addAuthHeader(RequestInterface $request)
{
Expand Down
11 changes: 0 additions & 11 deletions lib/Imgur/Middleware/ErrorMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public function __construct(callable $nextHandler)
}

/**
* @param RequestInterface $request
* @param array $options
*
* @return PromiseInterface
*/
public function __invoke(RequestInterface $request, array $options)
Expand All @@ -50,8 +47,6 @@ public static function error()

/**
* Check for an error.
*
* @param ResponseInterface $response
*/
public function checkError(ResponseInterface $response)
{
Expand Down Expand Up @@ -96,8 +91,6 @@ public function checkError(ResponseInterface $response)

/**
* Check if user hit limit.
*
* @param ResponseInterface $response
*/
private function checkUserRateLimit(ResponseInterface $response)
{
Expand All @@ -111,8 +104,6 @@ private function checkUserRateLimit(ResponseInterface $response)

/**
* Check if client hit limit.
*
* @param ResponseInterface $response
*/
private function checkClientRateLimit(ResponseInterface $response)
{
Expand All @@ -129,8 +120,6 @@ private function checkClientRateLimit(ResponseInterface $response)

/**
* Check if client hit post limit.
*
* @param ResponseInterface $response
*/
private function checkPostRateLimit(ResponseInterface $response)
{
Expand Down
Loading

0 comments on commit 65a5fa4

Please sign in to comment.