Skip to content

Commit 27903aa

Browse files
authored
Add method to retrieve currently configured strategies (#172)
* Add method to retrieve currently configured strategies
1 parent 7c36d95 commit 27903aa

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Support discovering PSR-17 factories of `guzzlehttp/psr7` package
88
- Support discovering PSR-17 factories of `laminas/laminas-diactoros` pakcage
9+
- `ClassDiscovery::getStrategies()` to retrieve the list of current strategies.
910

1011
## 1.7.4 - 2020-01-03
1112

spec/ClassDiscoverySpec.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ function it_prepends_strategies() {
6868
$this->find('Foobar')->shouldReturn('Added');
6969
}
7070

71+
function it_retrieves_configured_strategies() {
72+
$expect = [DiscoveryHelper::class];
73+
$this->getStrategies()->shouldReturn($expect);
74+
}
75+
7176
function it_appends_strategies() {
7277
$candidate = ['class' => 'Added'];
7378
DiscoveryHelper::setClasses('Foobar', [$candidate]);

src/ClassDiscovery.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ public static function setStrategies(array $strategies)
124124
self::clearCache();
125125
}
126126

127+
/**
128+
* Returns the currently configured discovery strategies as fully qualified class names.
129+
*
130+
* @return string[]
131+
*/
132+
public static function getStrategies(): iterable
133+
{
134+
return self::$strategies;
135+
}
136+
127137
/**
128138
* Append a strategy at the end of the strategy queue.
129139
*

0 commit comments

Comments
 (0)