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