ServiceConfigStdClassFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 0
loc 62
rs 10
c 3
b 0
f 0
eloc 12
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getApplicationOptions() 0 3 1
A __invoke() 0 11 1
A getServiceOptions() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ArpTest\LaminasFactory\TestDouble;
6
7
use Arp\LaminasFactory\AbstractFactory;
8
use Psr\Container\ContainerExceptionInterface;
9
use Psr\Container\ContainerInterface;
10
11
class ServiceConfigStdClassFactory extends AbstractFactory
12
{
13
    /**
14
     * @var array<mixed>|null
15
     */
16
    private ?array $applicationOptions;
17
18
    /**
19
     * @var array<mixed>|null
20
     */
21
    private ?array $serviceOptions;
22
23
    /**
24
     * @param array<mixed>|null $factoryOptions
25
     * @param array<mixed>|null $applicationOptions
26
     * @param array<mixed>|null $serviceOptions
27
     */
28
    public function __construct(
29
        ?array $factoryOptions = null,
30
        ?array $applicationOptions = null,
31
        ?array $serviceOptions = null
32
    ) {
33
        $this->applicationOptions = $applicationOptions;
34
        $this->serviceOptions = $serviceOptions;
35
36
        parent::__construct($factoryOptions);
37
    }
38
39
    /**
40
     * @param array<mixed>|null $options
41
     *
42
     * @throws ContainerExceptionInterface
43
     */
44
    public function __invoke(
45
        ContainerInterface $container,
46
        string $requestedName,
47
        array $options = null
48
    ): \stdClass {
49
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
50
51
        $object = new \stdClass();
52
        $object->options = $options;
53
54
        return $object;
55
    }
56
57
    /**
58
     * @return array<mixed>
59
     * @throws ContainerExceptionInterface
60
     */
61
    public function getApplicationOptions(ContainerInterface $container, ?string $optionsKey = null): array
62
    {
63
        return $this->applicationOptions ?? parent::getApplicationOptions($container, $optionsKey);
64
    }
65
66
    /**
67
     * @return array<mixed>
68
     * @throws ContainerExceptionInterface
69
     */
70
    public function getServiceOptions(ContainerInterface $container, string $requestedName, ?string $key = null): array
71
    {
72
        return $this->serviceOptions ?? parent::getServiceOptions($container, $requestedName, $key);
73
    }
74
}
75