Skip to content

Commit

Permalink
Added discovery strategy (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm committed May 22, 2017
1 parent c532ca4 commit 92abf02
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Httplug/DiscoveryStrategy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Nyholm\Psr7\Httplug;

use Http\Discovery\Strategy\DiscoveryStrategy as HttplugDiscoveryStrategy;
use Nyholm\Psr7\Factory\MessageFactory;
use Nyholm\Psr7\Factory\StreamFactory;
use Nyholm\Psr7\Factory\UriFactory;

/**
* A discovery strategy to use our factories with HTTPlug auto discovery.
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class DiscoveryStrategy implements HttplugDiscoveryStrategy
{
/**
* @var array
*/
private static $classes = [
'Http\Message\MessageFactory' => [
['class' => MessageFactory::class],
],
'Http\Message\StreamFactory' => [
['class' => StreamFactory::class],
],
'Http\Message\UriFactory' => [
['class' => UriFactory::class],
],
];

/**
* {@inheritdoc}
*/
public static function getCandidates($type)
{
if (isset(self::$classes[$type])) {
return self::$classes[$type];
}

return [];
}
}

0 comments on commit 92abf02

Please sign in to comment.