Completed
Pull Request — master (#11)
by Timothy
03:13
created

ModuleOptionsFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createService() 0 12 2
A getFiles() 0 8 1
1
<?php
2
3
namespace Abacaphiliac\ZendPhpDotEnv\Options;
4
5
use Zend\ServiceManager\FactoryInterface;
6
use Zend\ServiceManager\ServiceLocatorInterface;
7
8
class ModuleOptionsFactory implements FactoryInterface
9
{
10
    /**
11
     * Create service
12
     *
13
     * @param ServiceLocatorInterface $serviceLocator
14
     * @return ModuleOptions
15
     * @throws \Zend\Stdlib\Exception\InvalidArgumentException
16
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
17
     */
18
    public function createService(ServiceLocatorInterface $serviceLocator)
19
    {
20
        $options = new ModuleOptions();
21
22
        $config = $serviceLocator->get('config');
23
24
        if (array_key_exists('abacaphiliac/zend-phpdotenv', $config)) {
25
            $options->setFromArray($config['abacaphiliac/zend-phpdotenv']);
26
        }
27
28
        return $options;
29
    }
30
31
    /**
32
     * @param ServiceLocatorInterface $serviceLocator
33
     * @return string[]
34
     * @throws \Zend\Stdlib\Exception\InvalidArgumentException
35
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
36
     */
37
    public static function getFiles(ServiceLocatorInterface $serviceLocator)
38
    {
39
        $factory = new self;
40
41
        $options = $factory->createService($serviceLocator);
42
43
        return $options->getFiles();
44
    }
45
}
46