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

ModuleOptionsFactory::getFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 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