1 | <?php |
||
22 | class FixtureContainerFactory implements ContainerFactory |
||
23 | { |
||
24 | |||
25 | private $flattener; |
||
26 | |||
27 | public function __construct() |
||
31 | |||
32 | public function createFromFile($configFile) |
||
33 | { |
||
34 | $configPath = PathFactory::instance()->create($configFile); |
||
35 | $loadConfigFile = $configPath->normalize(); |
||
36 | |||
37 | if (file_exists($loadConfigFile) === false) { |
||
38 | throw new ConfigFileNotFoundException($loadConfigFile); |
||
39 | } |
||
40 | |||
41 | $configDirectory = $configPath->parent(); |
||
42 | |||
43 | $configValues = Toml::parse( $loadConfigFile ); |
||
44 | $result = $this->flattener->flatten($configValues); |
||
45 | |||
46 | foreach ($result as $key => $fixturePath) { |
||
47 | $fixtureRelativePath = RelativePath::fromString($fixturePath); |
||
48 | $fixturePath = $configDirectory->join($fixtureRelativePath); |
||
49 | $result[$key] = (string) $fixturePath->normalize(); |
||
50 | } |
||
51 | |||
52 | return new FixtureContainer($result); |
||
53 | } |
||
54 | |||
55 | public function createFromArray(array $values = []) |
||
60 | |||
61 | } |
||
62 |