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