Skip to content

Commit 57eb7e4

Browse files
authored
Add prepend and append strategy (#68)
Added Prepend and Append strategies
1 parent 94238b9 commit 57eb7e4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/ClassDiscovery.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Http\Discovery\Exception\DiscoveryFailedException;
66
use Http\Discovery\Exception\StrategyUnavailableException;
7+
use Http\Discovery\Strategy\DiscoveryStrategy;
78

89
/**
910
* Registry that based find results on class existence.
@@ -108,14 +109,36 @@ private static function storeInCache($type, $class)
108109
/**
109110
* Set new strategies and clear the cache.
110111
*
111-
* @param array $strategies
112+
* @param DiscoveryStrategy[] $strategies
112113
*/
113114
public static function setStrategies(array $strategies)
114115
{
115116
self::$strategies = $strategies;
116117
self::clearCache();
117118
}
118119

120+
/**
121+
* Append a strategy at the end of the strategy queue.
122+
*
123+
* @param DiscoveryStrategy $strategy
124+
*/
125+
public static function appendStrategy(DiscoveryStrategy $strategy)
126+
{
127+
self::$strategies[] = $strategy;
128+
self::clearCache();
129+
}
130+
131+
/**
132+
* Prepend a strategy at the beginning of the strategy queue.
133+
*
134+
* @param DiscoveryStrategy $strategy
135+
*/
136+
public static function prependStrategy(DiscoveryStrategy $strategy)
137+
{
138+
self::$strategies = array_unshift(self::$strategies, $strategy);
139+
self::clearCache();
140+
}
141+
119142
/**
120143
* Clear the cache.
121144
*/

0 commit comments

Comments
 (0)