1: <?php
2:
3: namespace PHPixie\Config;
4:
5: class Builder
6: {
7: protected $slice;
8: protected $instances = array();
9:
10: public function __construct($slice)
11: {
12: $this->slice = $slice;
13: }
14:
15: public function storages()
16: {
17: return $this->getInstance('storages');
18: }
19:
20: public function formats()
21: {
22: return $this->getInstance('formats');
23: }
24:
25: protected function getInstance($name)
26: {
27: if(!array_key_exists($name, $this->instances)) {
28: $method = 'build'.ucfirst($name);
29: $this->instances[$name] = $this->$method();
30: }
31:
32: return $this->instances[$name];
33: }
34:
35: protected function buildStorages()
36: {
37: return new Storages($this, $this->slice);
38: }
39:
40: protected function buildFormats()
41: {
42: return new Formats();
43: }
44: }