Passed
Push — main ( 7d5fab...06ee14 )
by Chema
04:05
created

SetupInitializer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A initializeFromTransfer() 0 18 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Bootstrap\Setup;
6
7
use Gacela\Framework\Bootstrap\SetupGacela;
8
9
/**
10
 * Initializes a SetupGacela instance from a GacelaConfigTransfer DTO.
11
 * This class encapsulates the logic for populating all properties from the transfer object.
12
 */
13
final class SetupInitializer
14
{
15
    public function __construct(
16
        private readonly SetupGacela $setup,
17
    ) {
18
    }
19
20
    public function initializeFromTransfer(GacelaConfigTransfer $dto): SetupGacela
21
    {
22
        return $this->setup
23
            ->setExternalServices($dto->externalServices)
24
            ->setAppConfigBuilder($dto->appConfigBuilder)
25
            ->setSuffixTypesBuilder($dto->suffixTypesBuilder)
26
            ->setBindingsBuilder($dto->bindingsBuilder)
27
            ->setShouldResetInMemoryCache($dto->shouldResetInMemoryCache)
28
            ->setFileCacheEnabled($dto->fileCacheEnabled)
29
            ->setFileCacheDirectory($dto->fileCacheDirectory)
30
            ->setProjectNamespaces($dto->projectNamespaces)
31
            ->setConfigKeyValues($dto->configKeyValues)
32
            ->setAreEventListenersEnabled($dto->areEventListenersEnabled)
33
            ->setGenericListeners($dto->genericListeners)
34
            ->setSpecificListeners($dto->specificListeners)
35
            ->setGacelaConfigsToExtend($dto->gacelaConfigsToExtend)
36
            ->setPlugins($dto->plugins)
37
            ->setServicesToExtend($dto->servicesToExtend);
38
    }
39
}
40