__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 2
rs 10
1
<?php
2
3
namespace Locastic\Loggastic\Metadata\LoggableContext\Factory;
4
5
use Locastic\Loggastic\Metadata\Extractor\LoggableExtractorInterface;
6
use Locastic\Loggastic\Metadata\LoggableContext\LoggableContextCollection;
7
8
final class ExtractorLoggableContextCollectionFactory implements LoggableContextCollectionFactoryInterface
9
{
10
    public function __construct(private readonly LoggableExtractorInterface $extractor, private readonly ?\Locastic\Loggastic\Metadata\LoggableContext\Factory\LoggableContextCollectionFactoryInterface $decorated = null)
11
    {
12
    }
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function create(): LoggableContextCollection
18
    {
19
        $loggableClasses = [];
20
        if ($this->decorated) {
21
            foreach ($this->decorated->create() as $loggableClass => $config) {
22
                $loggableClasses[$loggableClass] = $config;
23
            }
24
        }
25
26
        foreach ($this->extractor->getLoggableResources() as $loggableClass => $config) {
27
            $loggableClasses[$loggableClass] = $config;
28
        }
29
30
        return new LoggableContextCollection($loggableClasses);
31
    }
32
}
33