EntityComponent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getWorkers() 0 5 1
A getManagerWorker() 0 3 1
A getDatasourceProviderWorker() 0 3 1
A getRepository() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Derafu: Biblioteca PHP (Núcleo).
7
 * Copyright (C) Derafu <https://www.derafu.org>
8
 *
9
 * Este programa es software libre: usted puede redistribuirlo y/o modificarlo
10
 * bajo los términos de la Licencia Pública General Affero de GNU publicada por
11
 * la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, o
12
 * (a su elección) cualquier versión posterior de la misma.
13
 *
14
 * Este programa se distribuye con la esperanza de que sea útil, pero SIN
15
 * GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD
16
 * PARA UN PROPÓSITO DETERMINADO. Consulte los detalles de la Licencia Pública
17
 * General Affero de GNU para obtener una información más detallada.
18
 *
19
 * Debería haber recibido una copia de la Licencia Pública General Affero de GNU
20
 * junto a este programa.
21
 *
22
 * En caso contrario, consulte <http://www.gnu.org/licenses/agpl.html>.
23
 */
24
25
namespace Derafu\Lib\Core\Package\Prime\Component\Entity;
26
27
use Derafu\Lib\Core\Foundation\Abstract\AbstractComponent;
28
use Derafu\Lib\Core\Package\Prime\Component\Entity\Contract\DatasourceProviderWorkerInterface;
29
use Derafu\Lib\Core\Package\Prime\Component\Entity\Contract\EntityComponentInterface;
30
use Derafu\Lib\Core\Package\Prime\Component\Entity\Contract\ManagerWorkerInterface;
31
use Derafu\Lib\Core\Package\Prime\Component\Entity\Contract\RepositoryInterface;
32
33
/**
34
 * Componente "prime.entity".
35
 */
36
class EntityComponent extends AbstractComponent implements EntityComponentInterface
37
{
38
    public function __construct(
39
        private ManagerWorkerInterface $manager,
40
        private DatasourceProviderWorkerInterface $datasourceProvider
41
    ) {
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function getWorkers(): array
48
    {
49
        return [
50
            'manager' => $this->manager,
51
            'datasource_provider' => $this->datasourceProvider,
52
        ];
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     */
58
    public function getManagerWorker(): ManagerWorkerInterface
59
    {
60
        return $this->manager;
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66
    public function getDatasourceProviderWorker(): DatasourceProviderWorkerInterface
67
    {
68
        return $this->datasourceProvider;
69
    }
70
71
    /**
72
     * {@inheritDoc}
73
     */
74
    public function getRepository(string $source): RepositoryInterface
75
    {
76
        return $this->manager->getRepository($source);
77
    }
78
}
79