Skip to content

Fix error when "Imgur is temporarily over capacity" #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
<?php

return Symfony\CS\Config\Config::create()
->setUsingCache(true)
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
// use default SYMFONY_LEVEL and extra fixers:
->fixers(array(
'concat_with_spaces',
'ordered_use',
'phpdoc_order',
'strict',
'strict_param',
'short_array_syntax',
))
->finder(
Symfony\CS\Finder::create()
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => [
'syntax' => 'short'
],
'combine_consecutive_unsets' => true,
'heredoc_to_nowdoc' => true,
'no_extra_consecutive_blank_lines' => [
'break',
'continue',
'extra',
'return',
'throw',
'use',
'parenthesis_brace_block',
'square_brace_block',
'curly_brace_block'
],
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
// 'psr4' => true,
'strict_comparison' => true,
'strict_param' => true,
'concat_space' => [
'spacing' => 'one'
],
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude([
'vendor',
])
->in(__DIR__)
->exclude(array('vendor'))
)
;
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- nightly
- hhvm

# run build against nightly but allow them to fail
matrix:
fast_finish: true
include:
- php: 7.0
- php: 7.2
env: CS_FIXER=run
allow_failures:
- php: hhvm
- php: nightly

# faster builds on new travis setup not using sudo
Expand All @@ -34,7 +33,7 @@ before_script:
- composer install --prefer-dist --no-interaction

script:
- phpunit --coverage-clover=coverage.clover
- ./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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Uses [Imgur API v3](https://api.imgur.com/).
* Branch [2.x](https://github.com/j0k3r/php-imgur-api-client/tree/2.x) use Guzzle 5
* Branch [3.x](https://github.com/j0k3r/php-imgur-api-client/tree/3.x) use Guzzle 6

All actives branches required PHP >= 5.5
All actives branches required PHP >= 5.6

## Composer

Expand Down Expand Up @@ -52,7 +52,7 @@ if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);

if ($client->checkAccessTokenExpired()) {
$client->refreshToken();
$client->refreshToken();
}
} elseif (isset($_GET['code'])) {
$client->requestAccessToken($_GET['code']);
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
}
},
"require": {
"php": ">=5.5.0",
"php": ">=5.6.0",
"ext-curl": "*",
"guzzlehttp/guzzle": "^5.3.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.9"
"friendsofphp/php-cs-fixer": "~2.11",
"symfony/phpunit-bridge": "^4.0"
},
"extra": {
"branch-alias": {
Expand Down
28 changes: 14 additions & 14 deletions lib/Imgur/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ public function delete($url, $parameters = [])
return $httpClient->parseResponse($response);
}

/**
* Global method to validate an argument.
*
* @param string $type The required parameter (used for the error message)
* @param string $input Input value
* @param array $possibleValues Possible values for this argument
*/
private function validateArgument($type, $input, $possibleValues)
{
if (!in_array($input, $possibleValues, true)) {
throw new InvalidArgumentException($type . ' parameter "' . $input . '" is wrong. Possible values are: ' . implode(', ', $possibleValues));
}
}

/**
* Validate "sort" parameter and throw an exception if it's a bad value.
*
Expand Down Expand Up @@ -144,4 +130,18 @@ protected function validateVoteArgument($vote, $possibleValues)
{
$this->validateArgument('Vote', $vote, $possibleValues);
}

/**
* Global method to validate an argument.
*
* @param string $type The required parameter (used for the error message)
* @param string $input Input value
* @param array $possibleValues Possible values for this argument
*/
private function validateArgument($type, $input, $possibleValues)
{
if (!\in_array($input, $possibleValues, true)) {
throw new InvalidArgumentException($type . ' parameter "' . $input . '" is wrong. Possible values are: ' . implode(', ', $possibleValues));
}
}
}
Loading