Skip to content

Applied fixes from StyleCI #31

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 1 commit into from
Dec 17, 2015
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
10 changes: 5 additions & 5 deletions src/ClassDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function register($class, $condition = null)
static::$cache = null;

$definition = [
'class' => $class,
'class' => $class,
'condition' => isset($condition) ? $condition : $class,
];

Expand All @@ -38,14 +38,14 @@ public static function find()
{
// We have a cache
if (isset(static::$cache)) {
return new static::$cache;
return new static::$cache();
}

foreach (static::$classes as $name => $definition) {
if (static::evaluateCondition($definition['condition'])) {
static::$cache = $definition['class'];

return new $definition['class'];
return new $definition['class']();
}
}

Expand All @@ -57,7 +57,7 @@ public static function find()
*
* @param mixed $condition
*
* @return boolean
* @return bool
*/
protected static function evaluateCondition($condition)
{
Expand All @@ -72,7 +72,7 @@ protected static function evaluateCondition($condition)
$evaluatedCondition = true;

// Immediately stop execution if the condition is false
for ($i = 0; $i < count($condition) && false !== $evaluatedCondition; $i++) {
for ($i = 0; $i < count($condition) && false !== $evaluatedCondition; ++$i) {
$evaluatedCondition &= static::evaluateCondition($condition[$i]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/HttpAsyncClientDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class HttpAsyncClientDiscovery extends ClassDiscovery
*/
protected static $classes = [
'guzzle6' => [
'class' => 'Http\Adapter\Guzzle6HttpAdapter',
'class' => 'Http\Adapter\Guzzle6HttpAdapter',
'condition' => 'Http\Adapter\Guzzle6HttpAdapter',
],
];
Expand Down
4 changes: 2 additions & 2 deletions src/HttpClientDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ final class HttpClientDiscovery extends ClassDiscovery
*/
protected static $classes = [
'guzzle6' => [
'class' => 'Http\Adapter\Guzzle6HttpAdapter',
'class' => 'Http\Adapter\Guzzle6HttpAdapter',
'condition' => 'Http\Adapter\Guzzle6HttpAdapter',
],
'guzzle5' => [
'class' => 'Http\Adapter\Guzzle5HttpAdapter',
'class' => 'Http\Adapter\Guzzle5HttpAdapter',
'condition' => 'Http\Adapter\Guzzle5HttpAdapter',
],
];
Expand Down
4 changes: 2 additions & 2 deletions src/MessageFactoryDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ final class MessageFactoryDiscovery extends FactoryDiscovery
*/
protected static $classes = [
'guzzle' => [
'class' => 'Http\Client\Utils\MessageFactory\GuzzleMessageFactory',
'class' => 'Http\Client\Utils\MessageFactory\GuzzleMessageFactory',
'condition' => [
'Http\Client\Utils\MessageFactory\GuzzleMessageFactory',
'GuzzleHttp\Psr7\Request',
],
],
'diactoros' => [
'class' => 'Http\Client\Utils\MessageFactory\DiactorosMessageFactory',
'class' => 'Http\Client\Utils\MessageFactory\DiactorosMessageFactory',
'condition' => [
'Http\Client\Utils\MessageFactory\DiactorosMessageFactory',
'Zend\Diactoros\Request',
Expand Down
4 changes: 2 additions & 2 deletions src/StreamFactoryDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ final class StreamFactoryDiscovery extends FactoryDiscovery
*/
protected static $classes = [
'guzzle' => [
'class' => 'Http\Client\Utils\StreamFactory\GuzzleStreamFactory',
'class' => 'Http\Client\Utils\StreamFactory\GuzzleStreamFactory',
'condition' => [
'Http\Client\Utils\StreamFactory\GuzzleStreamFactory',
'GuzzleHttp\Psr7\Stream',
],
],
'diactoros' => [
'class' => 'Http\Client\Utils\StreamFactory\DiactorosStreamFactory',
'class' => 'Http\Client\Utils\StreamFactory\DiactorosStreamFactory',
'condition' => [
'Http\Client\Utils\StreamFactory\DiactorosStreamFactory',
'Zend\Diactoros\Stream',
Expand Down
4 changes: 2 additions & 2 deletions src/UriFactoryDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ final class UriFactoryDiscovery extends FactoryDiscovery
*/
protected static $classes = [
'guzzle' => [
'class' => 'Http\Client\Utils\UriFactory\GuzzleUriFactory',
'class' => 'Http\Client\Utils\UriFactory\GuzzleUriFactory',
'condition' => [
'Http\Client\Utils\UriFactory\GuzzleUriFactory',
'GuzzleHttp\Psr7\Uri',
],
],
'diactoros' => [
'class' => 'Http\Client\Utils\UriFactory\DiactorosUriFactory',
'class' => 'Http\Client\Utils\UriFactory\DiactorosUriFactory',
'condition' => [
'Http\Client\Utils\UriFactory\DiactorosUriFactory',
'Zend\Diactoros\Uri',
Expand Down