Completed
Pull Request — master (#11)
by Timothy
02:08
created

ModuleOptionsFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 38
ccs 11
cts 11
cp 1
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 3
    public function createService(ServiceLocatorInterface $serviceLocator)
19
    {
20 3
        $options = new ModuleOptions();
21
22 3
        $config = $serviceLocator->get('config');
23
24 3
        if (array_key_exists('abacaphiliac/zend-phpdotenv', $config)) {
25 2
            $options->setFromArray($config['abacaphiliac/zend-phpdotenv']);
26 2
        }
27
28 3
        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 1
    public static function getFiles(ServiceLocatorInterface $serviceLocator)
38
    {
39 1
        $factory = new self;
40
41 1
        $options = $factory->createService($serviceLocator);
42
43 1
        return $options->getFiles();
44
    }
45
}
46