1 | <?php |
||
19 | final class ProjectFactoryStrategies implements StrategyContainer |
||
20 | { |
||
21 | /** |
||
22 | * @var ProjectFactoryStrategy[] |
||
23 | */ |
||
24 | private $strategies; |
||
25 | |||
26 | /** |
||
27 | * Initializes the factory with a number of strategies. |
||
28 | * |
||
29 | * @param ProjectFactoryStrategy[] $strategies |
||
30 | */ |
||
31 | 1 | public function __construct(array $strategies) |
|
32 | { |
||
33 | 1 | foreach ($strategies as $strategy) { |
|
34 | 1 | $this->addStrategy($strategy); |
|
35 | } |
||
36 | |||
37 | 1 | $this->strategies = $strategies; |
|
38 | 1 | } |
|
39 | |||
40 | /** |
||
41 | * Find the ProjectFactoryStrategy that matches $object. |
||
42 | * |
||
43 | * |
||
44 | * @param mixed $object |
||
45 | * @throws OutOfBoundsException when no matching strategy was found. |
||
46 | */ |
||
47 | 2 | public function findMatching($object): ProjectFactoryStrategy |
|
62 | |||
63 | /** |
||
64 | * Add a strategy to this container. |
||
65 | */ |
||
66 | 1 | public function addStrategy(ProjectFactoryStrategy $strategy): void |
|
70 | } |
||
71 |