AuthOptionsFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
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 AuthOptionsFactory
16
 */
17
class AuthOptionsFactory implements FactoryInterface
18
{
19
    /**
20
     * @param ContainerInterface $container
21
     * @param string             $requestedName
22
     * @param array|null         $options
23
     *
24
     * @return AuthOptions
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
    ): AuthOptions {
34 2
        $config = $container->get('Config');
35 2
        $settingsArr = $config[Module::INVOICE_NINJA_CONFIG] ?? [];
36 2
        $authArr = $settingsArr[Module::AUTHORIZATION] ?? [];
37 2
        return new AuthOptions($authArr);
38
    }
39
}
40