Skip to content

Add method to retrieve currently configured strategies #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

## 1.7.4 - 2020-01-03

Expand Down
5 changes: 5 additions & 0 deletions spec/ClassDiscoverySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ function it_prepends_strategies() {
$this->find('Foobar')->shouldReturn('Added');
}

function it_retrieves_configured_strategies() {
$expect = [DiscoveryHelper::class];
$this->getStrategies()->shouldReturn($expect);
}

function it_appends_strategies() {
$candidate = ['class' => 'Added'];
DiscoveryHelper::setClasses('Foobar', [$candidate]);
Expand Down
10 changes: 10 additions & 0 deletions src/ClassDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ public static function setStrategies(array $strategies)
self::clearCache();
}

/**
* Returns the currently configured discovery strategies as fully qualified class names.
*
* @return string[]
*/
public static function getStrategies(): iterable
{
return self::$strategies;
}

/**
* Append a strategy at the end of the strategy queue.
*
Expand Down