| Conditions | 5 |
| Paths | 8 |
| Total Lines | 29 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public function createService(ServiceLocatorInterface $serviceLocator) |
||
| 24 | { |
||
| 25 | $config = $serviceLocator->get('Config'); |
||
| 26 | |||
| 27 | if (array_key_exists('storage_options', $config['phpab'])) { |
||
| 28 | $options = $config['phpab']['storage_options']; |
||
| 29 | } else { |
||
| 30 | $options = []; |
||
| 31 | } |
||
| 32 | |||
| 33 | switch ($config['phpab']['storage']) { |
||
| 34 | case 'cookie': |
||
| 35 | $adapter = new Cookie($options['name'], $options['ttl']); |
||
| 36 | break; |
||
| 37 | |||
| 38 | case 'runtime': |
||
| 39 | $adapter = new Runtime(); |
||
| 40 | break; |
||
| 41 | |||
| 42 | case 'session': |
||
| 43 | $adapter = new ZendSession($options['name']); |
||
| 44 | break; |
||
| 45 | |||
| 46 | default: |
||
| 47 | throw new RuntimeException('Invalid storage adapter set: ' . $config['phpab']['storage']); |
||
| 48 | } |
||
| 49 | |||
| 50 | return new Storage($adapter); |
||
| 51 | } |
||
| 52 | |||
| 57 |