Skip to content

Commit 4049c30

Browse files
committed
Merge pull request #18 from sandrokeil/develop
Improved interfaces and naming
2 parents 35b8fad + b8cc50d commit 4049c30

33 files changed

Lines changed: 853 additions & 346 deletions

CHANGELOG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 0.3.0 TBD
5+
## 0.3.0 (2015-10-18)
66

77
### Added
88

9-
* [#8](https://github.com/sandrokeil/interop-config/issues/8): Introducing HasOptionalOptions Interface
10-
* [#9](https://github.com/sandrokeil/interop-config/issues/9): Introducing HasDefaultOptions Interface
9+
* [#9](https://github.com/sandrokeil/interop-config/issues/9): Introducing ProvidesDefaultOptions interface
1110
* [#13](https://github.com/sandrokeil/interop-config/issues/13): Support for recursive mandatory options check
11+
* `canRetrieveOptions()` to `ConfigurationTrait` to perform the options check without throwing an exception
12+
* `optionsWithFallback()` to `ConfigurationTrait` which uses default options if config can not be retrieved
13+
* OptionNotFoundException and MandatoryOptionNotFoundException extends OutOfBoundsException instead of RuntimeException
14+
* Check if retrieved options are an array or an instance of ArrayAccess
1215
* Benchmark suite
16+
* Updated documentation
1317

1418
### Deprecated
1519

1620
* Nothing
1721

1822
### Removed
1923

20-
* Nothing
24+
* `HasConfig` interface, was renamed to `RequiresConfig`
25+
* `HasContainer` interface, was renamed to `RequiresContainerId`
26+
* `HasMandatoryOptions` interface, was renamed to `RequiresMandatoryOptions`
27+
* `HasDefaultOptions` interface, was renamed to `ProvidesDefaultOptions`
28+
* `ObtainsOptions` interface, was merged in `RequiresConfig`
29+
* `OptionalOptions` interface, can be achieved via `ProvidesDefaultOptions`
2130

2231
### Fixed
2332

README.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
> You want to configure your factories?
44
5-
> You want to check automatically for mandatory params?
5+
> You want to reduce your factory boilerplate code?
6+
7+
> You want to check automatically for mandatory options?
68
79
> You want to have an uniform config structure?
810
@@ -24,7 +26,7 @@ and to create configuration files.
2426

2527
> Please join the discussion about the [PSR config proposal](https://github.com/php-fig/fig-standards/pull/620).
2628
27-
* **Well tested.** Besides unit test and continuous integration/inspection this solution is also ~~ready for production use~~.
29+
* **Well tested.** Besides unit test and continuous integration/inspection this solution is also ready for production use.
2830
* **Framework agnostic** This PHP library does not depends on any framework but you can use it with your favourite framework.
2931
* **Every change is tracked**. Want to know whats new? Take a look at [CHANGELOG.md](https://github.com/sandrokeil/interop-config/blob/master/CHANGELOG.md)
3032
* **Listen to your ideas.** Have a great idea? Bring your tested pull request or open a new issue. See [CONTRIBUTING.md](CONTRIBUTING.md)
@@ -65,11 +67,11 @@ the logic to retrieve the options from a configuration. See documentation for mo
6567
6668
```php
6769
use Interop\Config\ConfigurationTrait;
68-
use Interop\Config\HasMandatoryOptions;
69-
use Interop\Config\HasContainerId;
70+
use Interop\Config\RequiresContainerId;
71+
use Interop\Config\RequiresMandatoryOptions;
7072
use Interop\Container\ContainerInterface;
7173

72-
class MyDBALConnectionFactory implements HasMandatoryOptions, HasContainerId
74+
class MyDBALConnectionFactory implements RequiresContainerId, RequiresMandatoryOptions
7375
{
7476
use ConfigurationTrait;
7577

@@ -78,7 +80,7 @@ class MyDBALConnectionFactory implements HasMandatoryOptions, HasContainerId
7880
// get options for doctrine.connection.orm_default
7981
$options = $this->options($container->get('config'));
8082

81-
// mandatory options check is automatically done by MandatoryOptionsInterface
83+
// mandatory options check is automatically done by RequiresMandatoryOptions
8284

8385
$driverClass = $options['driverClass'];
8486
$params = $options['params'];
@@ -125,7 +127,7 @@ class MyDBALConnectionFactory implements HasMandatoryOptions, HasContainerId
125127
*/
126128
public function mandatoryOptions()
127129
{
128-
return ['driverClass', 'params'];
130+
return ['params' => ['user', 'password', 'dbname']];
129131
}
130132
}
131133
```
@@ -139,22 +141,38 @@ Put the following into your composer.json
139141

140142
{
141143
"require": {
142-
"sandrokeil/interop-config": "1.0.x-dev"
144+
"sandrokeil/interop-config": "^0.3"
143145
}
144146
}
145147

146148
## Documentation
149+
For the latest online documentation you can visit [http://sandrokeil.github.io/interop-config/](http://sandrokeil.github.io/interop-config/ "Latest interop-config documentation").
147150

148151
Documentation is [in the doc tree](doc/), and can be compiled using [bookdown](http://bookdown.io) and [Docker](https://www.docker.com/)
149152

150153
```console
151-
$ docker run -i -t=false --rm -v $(pwd):/app sandrokeil/bookdown doc/bookdown.json
152-
$ docker run -i -t=false --rm -p 8080:8080 -v $(pwd):/app php:5.6-cli php -S 0.0.0.0:8080 -t /app/doc/html
154+
$ docker run -it --rm -v $(pwd):/app sandrokeil/bookdown doc/bookdown.json
155+
$ docker run -it --rm -p 8080:8080 -v $(pwd):/app php:5.6-cli php -S 0.0.0.0:8080 -t /app/doc/html
153156
```
154157

155158
or make sure bookdown is installed globally via composer and `$HOME/.composer/vendor/bin` is on your `$PATH`.
156159

157160
```console
158161
$ bookdown doc/bookdown.json
159-
$ php -S 0.0.0.0:8080 -t doc/html/ # then browse to http://localhost:8080/
162+
$ php -S 0.0.0.0:8080 -t doc/html/
163+
```
164+
165+
Then browse to [http://localhost:8080/](http://localhost:8080/)
166+
167+
## Benchmarks
168+
The benchmarks uses [PHPBench](https://github.com/phpbench/phpbench) and can be started by the following command:
169+
170+
```console
171+
$ ./vendor/bin/phpbench run --report=aggregate
172+
```
173+
174+
or with Docker
175+
176+
```console
177+
$ docker run --rm -it --volume $(pwd):/app sandrokeil/php:5.6-cli php ./vendor/bin/phpbench run --report=aggregate
160178
```
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use InteropTest\Config\TestAsset\ConnectionDefaultOptionsConfiguration;
1313

1414
/**
15-
* @beforeMethod classSetUp
15+
* @BeforeMethods({"classSetUp"})
1616
*/
17-
class HasDefaultOptions
17+
class ProvidesDefaultOptions
1818
{
1919
private $config;
2020

@@ -32,8 +32,8 @@ public function classSetUp()
3232
/**
3333
* Retrieve options
3434
*
35-
* @revs 1000
36-
* @iterations 10
35+
* @Revs(10000)
36+
* @Iterations(10)
3737
*/
3838
public function benchOptions()
3939
{
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use InteropTest\Config\TestAsset\ConnectionConfiguration;
1313

1414
/**
15-
* @beforeMethod classSetUp
15+
* @BeforeMethods({"classSetUp"})
1616
*/
17-
class HasConfigBench
17+
class RequiresConfigBench
1818
{
1919
private $config;
2020

@@ -32,8 +32,8 @@ public function classSetUp()
3232
/**
3333
* Retrieve options
3434
*
35-
* @revs 1000
36-
* @iterations 10
35+
* @Revs(10000)
36+
* @Iterations(10)
3737
*/
3838
public function benchOptions()
3939
{
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use InteropTest\Config\TestAsset\ConnectionContainerIdConfiguration;
1313

1414
/**
15-
* @beforeMethod classSetUp
15+
* @BeforeMethods({"classSetUp"})
1616
*/
17-
class HasContainerId
17+
class RequiresContainerId
1818
{
1919
private $config;
2020

@@ -32,8 +32,8 @@ public function classSetUp()
3232
/**
3333
* Retrieve options
3434
*
35-
* @revs 1000
36-
* @iterations 10
35+
* @Revs(10000)
36+
* @Iterations(10)
3737
*/
3838
public function benchOptions()
3939
{

benchmark/HasMandatoryOptionsBench.php renamed to benchmark/RequiresMandatoryOptionsBench.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use InteropTest\Config\TestAsset\ConnectionMandatoryConfiguration;
1313

1414
/**
15-
* @beforeMethod classSetUp
15+
* @BeforeMethods({"classSetUp"})
1616
*/
17-
class HasMandatoryOptions
17+
class RequiresMandatoryOptions
1818
{
1919
private $config;
2020

@@ -32,8 +32,8 @@ public function classSetUp()
3232
/**
3333
* Retrieve options
3434
*
35-
* @revs 1000
36-
* @iterations 10
35+
* @Revs(10000)
36+
* @Iterations(10)
3737
*/
3838
public function benchOptions()
3939
{

benchmark/HasMandatoryOptionsContainerIdBench.php renamed to benchmark/RequiresMandatoryOptionsContainerIdBench.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use InteropTest\Config\TestAsset\ConnectionMandatoryContainerIdConfiguration;
1313

1414
/**
15-
* @beforeMethod classSetUp
15+
* @BeforeMethods({"classSetUp"})
1616
*/
17-
class HasMandatoryOptionsContainerId
17+
class RequiresMandatoryOptionsContainerId
1818
{
1919
private $config;
2020

@@ -32,8 +32,8 @@ public function classSetUp()
3232
/**
3333
* Retrieve options
3434
*
35-
* @revs 1000
36-
* @iterations 10
35+
* @Revs(10000)
36+
* @Iterations(10)
3737
*/
3838
public function benchOptions()
3939
{

benchmark/HasMandatoryOptionsRecursiveContainerIdBench.php renamed to benchmark/RequiresMandatoryOptionsRecursiveContainerIdBench.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use InteropTest\Config\TestAsset\ConnectionMandatoryRecursiveContainerIdConfiguration;
1313

1414
/**
15-
* @beforeMethod classSetUp
15+
* @BeforeMethods({"classSetUp"})
1616
*/
17-
class HasMandatoryOptionsRecursiveContainerId
17+
class RequiresMandatoryOptionsRecursiveContainerId
1818
{
1919
private $config;
2020

@@ -32,8 +32,8 @@ public function classSetUp()
3232
/**
3333
* Retrieve options
3434
*
35-
* @revs 1000
36-
* @iterations 10
35+
* @Revs(10000)
36+
* @Iterations(10)
3737
*/
3838
public function options()
3939
{

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"phpunit/phpunit": "~4.8",
4646
"phpunit/php-invoker": "~1.1",
4747
"squizlabs/php_codesniffer": "~2.3",
48-
"phpbench/phpbench": "dev-master"
48+
"phpbench/phpbench": "^0.5",
49+
"tobiju/bookdown-bootswatch-templates": "1.0.x-dev"
4950
},
5051
"minimum-stability": "dev",
5152
"prefer-stable": true,
@@ -57,12 +58,14 @@
5758
},
5859
"archive": {
5960
"exclude": [
61+
".coveralls.yml",
62+
".scrutinizer.yml",
63+
".travis.yml",
6064
"benchmark",
61-
"test",
65+
"build",
66+
"phpbench.json.dist",
6267
"phpunit.xml*",
63-
".travis.yml",
64-
".scrutinizer.yml",
65-
".coveralls.yml"
68+
"test"
6669
]
6770
}
6871
}

0 commit comments

Comments
 (0)