Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 1f6195f

Browse files
committed
Merge branch 'feature/allow-arrays'
Close #2
2 parents 296c2b5 + 64883f0 commit 1f6195f

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

.docheader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @see https://github.com/zendframework/zend-config-aggregator for the canonical source repository
3-
* @copyright Copyright (c) %regexp:(20\d{2}-)?%%year% Zend Technologies USA Inc. (http://www.zend.com)
3+
* @copyright Copyright (c) %regexp:(20\d{2}-)?20\d{2}% Zend Technologies USA Inc. (http://www.zend.com)
44
* @copyright Copyright (c) 2015-2016 Mateusz Tymek (http://mateusztymek.pl)
55
* @license https://github.com/zendframework/zend-config-aggregator/blob/master/LICENSE.md New BSD License
66
*/

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

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

5+
## 0.2.0 - 2017-01-11
6+
7+
### Added
8+
9+
- [#2](https://github.com/zendframework/zend-config-aggregator/pull/2) adds a
10+
new `ArrayProvider`, which accepts an array to its constructor, and returns
11+
it when invoked. This can be used to provide in-line array configuration when
12+
feeding the `ConfigAggregator` instance.
13+
14+
### Deprecated
15+
16+
- Nothing.
17+
18+
### Removed
19+
20+
- Nothing.
21+
22+
### Fixed
23+
24+
- Nothing.
25+
526
## 0.1.0 - 2016-12-08
627

728
Initial release.

src/ArrayProvider.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator for the canonical source repository
4+
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @copyright Copyright (c) 2015-2016 Mateusz Tymek (http://mateusztymek.pl)
6+
* @license https://github.com/zendframework/zend-config-aggregator/blob/master/LICENSE.md New BSD License
7+
*/
8+
9+
namespace Zend\ConfigAggregator;
10+
11+
/**
12+
* Provider that returns the array seeded to itself.
13+
*
14+
* Primary use case is configuration cache-related settings.
15+
*/
16+
class ArrayProvider
17+
{
18+
/**
19+
* @var array
20+
*/
21+
private $config;
22+
23+
/**
24+
* @param array $config
25+
*/
26+
public function __construct(array $config)
27+
{
28+
$this->config = $config;
29+
}
30+
31+
/**
32+
* @return array
33+
*/
34+
public function __invoke()
35+
{
36+
return $this->config;
37+
}
38+
}

test/ArrayProviderTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator for the canonical source repository
4+
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @copyright Copyright (c) 2015-2016 Mateusz Tymek (http://mateusztymek.pl)
6+
* @license https://github.com/zendframework/zend-config-aggregator/blob/master/LICENSE.md New BSD License
7+
*/
8+
9+
namespace ZendTest\ConfigAggregator;
10+
11+
use PHPUnit_Framework_TestCase as TestCase;
12+
use Zend\ConfigAggregator\ArrayProvider;
13+
14+
class ArrayProviderTest extends TestCase
15+
{
16+
public function testProviderIsCallable()
17+
{
18+
$provider = new ArrayProvider([]);
19+
$this->assertInternalType('callable', $provider);
20+
}
21+
22+
public function testProviderReturnsArrayProvidedAtConstruction()
23+
{
24+
$expected = [
25+
'foo' => 'bar',
26+
];
27+
$provider = new ArrayProvider($expected);
28+
29+
$this->assertSame($expected, $provider());
30+
}
31+
}

0 commit comments

Comments
 (0)