ModuleOptionsFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InvoiceNinjaModule\Options;
6
7
use InvoiceNinjaModule\Exception\InvalidParameterException;
8
use InvoiceNinjaModule\Module;
9
use Laminas\ServiceManager\Factory\FactoryInterface;
10
use Psr\Container\ContainerExceptionInterface;
11
use Psr\Container\ContainerInterface;
12
use Psr\Container\NotFoundExceptionInterface;
13
14
/**
15
 * Class ModuleOptionsFactory
16
 */
17
class ModuleOptionsFactory implements FactoryInterface
18
{
19
    /**
20
     * @param ContainerInterface $container
21
     * @param string             $requestedName
22
     * @param array|null         $options
23
     *
24
     * @return ModuleOptions
25
     * @throws InvalidParameterException
26
     * @throws ContainerExceptionInterface
27
     * @throws NotFoundExceptionInterface
28
     */
29 2
    public function __invoke(
30
        ContainerInterface $container,
31
        $requestedName,
32
        array $options = null
33
    ): ModuleOptions {
34 2
        $config = $container->get('Config');
35 2
        $settingsArr = $config[Module::INVOICE_NINJA_CONFIG] ?? [];
36 2
        return new ModuleOptions($settingsArr, $container->get(AuthOptions::class));
37
    }
38
}
39