Skip to content

Add http async client discovery #16

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
Nov 6, 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
23 changes: 23 additions & 0 deletions spec/HttpAsyncClientDiscoverySpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace spec\Http\Discovery;

use PhpSpec\ObjectBehavior;

class HttpAsyncClientDiscoverySpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Http\Discovery\HttpAsyncClientDiscovery');
}

function it_is_a_class_discovery()
{
$this->shouldHaveType('Http\Discovery\ClassDiscovery');
}

function it_finds_an_http_client()
{
$this->find()->shouldImplement('Http\Client\HttpAsyncClient');
}
}
2 changes: 1 addition & 1 deletion spec/HttpClientDiscoverySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function it_is_a_class_discovery()
$this->shouldHaveType('Http\Discovery\ClassDiscovery');
}

function it_finds_an_http_adapter()
function it_finds_an_http_client()
{
$this->find()->shouldImplement('Http\Client\HttpClient');
}
Expand Down
6 changes: 5 additions & 1 deletion spec/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
eval('namespace Http\Client; interface HttpClient {}');
}

if (!interface_exists('Http\Client\HttpAsyncClient')) {
eval('namespace Http\Client; interface HttpAsyncClient {}');
}

if (!class_exists('Http\Adapter\Guzzle6HttpAdapter')) {
eval('namespace Http\Adapter; class Guzzle6HttpAdapter implements \Http\Client\HttpClient {}');
eval('namespace Http\Adapter; class Guzzle6HttpAdapter implements \Http\Client\HttpClient, \Http\Client\HttpAsyncClient {}');
}

41 changes: 41 additions & 0 deletions src/HttpAsyncClientDiscovery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Http\Discovery;

use Http\Client\HttpAsyncClient;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't see it.


/**
* Finds an HTTP Asynchronous Client
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async term should be consistent

*
* @author Joel Wurtz <[email protected]>
*/
class HttpAsyncClientDiscovery extends ClassDiscovery
{
/**
* @var HttpAsyncClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be imported?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a use ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise IDEs won't find it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like i said it's done, github just don't show it here :) as it's from a old commit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great.

*/
protected static $cache;

/**
* @var array
*/
protected static $classes = [
'guzzle6' => [
'class' => 'Http\Adapter\Guzzle6HttpAdapter',
'condition' => 'Http\Adapter\Guzzle6HttpAdapter',
],
];

/**
* Finds an HTTP Async Client
*
* @return HttpAsyncClient
*
* @throws NotFoundException
*/
public static function find()
{
// Override only used for return type declaration
return parent::find();
}
}
7 changes: 3 additions & 4 deletions src/HttpClientDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ class HttpClientDiscovery extends ClassDiscovery
protected static $classes = [
'guzzle6' => [
'class' => 'Http\Adapter\Guzzle6HttpAdapter',
'condition' => 'Http\Adapter\Guzzle6HttpAdapter'

'condition' => 'Http\Adapter\Guzzle6HttpAdapter',
],
'guzzle5' => [
'class' => 'Http\Adapter\Guzzle5HttpAdapter',
'condition' => 'Http\Adapter\Guzzle5HttpAdapter'
'condition' => 'Http\Adapter\Guzzle5HttpAdapter',
],
];

/**
* Finds an HTTP Adapter
* Finds an HTTP Client
*
* @return HttpClient
*
Expand Down