Skip to content

Commit 961abf5

Browse files
committed
Move factories to php-http/utils
Remove factories from discovery Add better warning for missing factories Fix tests
1 parent d97c2f7 commit 961abf5

21 files changed

+78
-498
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ cache:
77
- $HOME/.composer/cache
88

99
php:
10-
- 5.4
1110
- 5.5
1211
- 5.6
1312
- 7.0
@@ -24,7 +23,7 @@ branches:
2423
matrix:
2524
fast_finish: true
2625
include:
27-
- php: 5.4
26+
- php: 5.5
2827
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"
2928

3029
before_install:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
"php-http/message-factory": "^1.0"
2020
},
2121
"require-dev": {
22+
"php-http/utils": "^0.2",
2223
"zendframework/zend-diactoros": "^1.0",
2324
"guzzlehttp/psr7": "^1.0",
2425
"php-http/guzzle6-adapter": "^0.2",
2526
"phpspec/phpspec": "^2.4",
2627
"henrikbjorn/phpspec-code-coverage" : "^1.0"
2728
},
2829
"suggest": {
29-
"zendframework/zend-diactoros": "Used with Diactoros Factories",
30-
"guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories"
30+
"php-http/utils": "To use Guzzle or Diactoros factories"
3131
},
3232
"autoload": {
3333
"psr-4": {

spec/MessageFactory/DiactorosMessageFactorySpec.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

spec/MessageFactory/GuzzleMessageFactorySpec.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

spec/MessageFactoryDiscoverySpec.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ function it_is_a_class_discovery()
1616
$this->shouldHaveType('Http\Discovery\ClassDiscovery');
1717
}
1818

19+
function it_is_a_factory_discovery()
20+
{
21+
$this->shouldHaveType('Http\Discovery\FactoryDiscovery');
22+
}
23+
1924
function it_finds_an_http_message_factory()
2025
{
2126
$this->find()->shouldHaveType('Http\Message\MessageFactory');

spec/StreamFactory/DiactorosStreamFactorySpec.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

spec/StreamFactory/GuzzleStreamFactorySpec.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

spec/StreamFactoryDiscoverySpec.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ function it_is_a_class_discovery()
1616
$this->shouldHaveType('Http\Discovery\ClassDiscovery');
1717
}
1818

19+
function it_is_a_factory_discovery()
20+
{
21+
$this->shouldHaveType('Http\Discovery\FactoryDiscovery');
22+
}
23+
1924
function it_finds_an_http_stream_factory()
2025
{
2126
$this->find()->shouldHaveType('Http\Message\StreamFactory');

spec/UriFactory/DiactorosUriFactorySpec.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

spec/UriFactory/GuzzleUriFactorySpec.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

spec/UriFactoryDiscoverySpec.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ function it_is_a_class_discovery()
1616
$this->shouldHaveType('Http\Discovery\ClassDiscovery');
1717
}
1818

19+
function it_is_a_factory_discovery()
20+
{
21+
$this->shouldHaveType('Http\Discovery\FactoryDiscovery');
22+
}
23+
1924
function it_finds_an_http_uri_factory()
2025
{
2126
$this->find()->shouldHaveType('Http\Message\UriFactory');

src/FactoryDiscovery.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Http\Discovery;
4+
5+
/**
6+
* Finds a Factory.
7+
*
8+
* @author Márk Sági-Kazár <[email protected]>
9+
*/
10+
abstract class FactoryDiscovery extends ClassDiscovery
11+
{
12+
/**
13+
* {@inheritdoc}
14+
*/
15+
public static function find()
16+
{
17+
try {
18+
return parent::find();
19+
} catch (NotFoundException $e) {
20+
throw new NotFoundException(
21+
'No factories found. Install php-http/utils >= 0.2 to use Guzzle or Diactoros factories.',
22+
0,
23+
$e
24+
);
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)