CertificateComponent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 74
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFakerWorker() 0 3 1
A getValidatorWorker() 0 3 1
A getLoaderWorker() 0 3 1
A getWorkers() 0 6 1
A __construct() 0 8 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\Certificate;
26
27
use Derafu\Lib\Core\Foundation\Abstract\AbstractComponent;
28
use Derafu\Lib\Core\Package\Prime\Component\Certificate\Contract\CertificateComponentInterface;
29
use Derafu\Lib\Core\Package\Prime\Component\Certificate\Contract\FakerWorkerInterface;
30
use Derafu\Lib\Core\Package\Prime\Component\Certificate\Contract\LoaderWorkerInterface;
31
use Derafu\Lib\Core\Package\Prime\Component\Certificate\Contract\ValidatorWorkerInterface;
32
33
/**
34
 * Servicio que gestiona todo lo asociado a certificados digitales (aka: firmas
35
 * electrónicas).
36
 */
37
class CertificateComponent extends AbstractComponent implements CertificateComponentInterface
38
{
39
    /**
40
     * Instancia que permite generar certificados autofirmados.
41
     *
42
     * @var FakerWorkerInterface
43
     */
44
    private FakerWorkerInterface $faker;
45
46
    /**
47
     * Instancia que permite cargar (crear) certificados a partir de sus datos.
48
     *
49
     * @var LoaderWorkerInterface
50
     */
51
    private LoaderWorkerInterface $loader;
52
53
    /**
54
     * Instancia que permite validar un certificado digital.
55
     *
56
     * @var ValidatorWorkerInterface
57
     */
58
    private ValidatorWorkerInterface $validator;
59
60
    /**
61
     * Constructor del componente.
62
     *
63
     * @param LoaderWorkerInterface $loader
64
     * @param ValidatorWorkerInterface $validator
65
     * @param FakerWorkerInterface $faker
66
     */
67
    public function __construct(
68
        FakerWorkerInterface $faker,
69
        LoaderWorkerInterface $loader,
70
        ValidatorWorkerInterface $validator,
71
    ) {
72
        $this->faker = $faker;
73
        $this->loader = $loader;
74
        $this->validator = $validator;
75
    }
76
77
    /**
78
     * {@inheritDoc}
79
     */
80
    public function getWorkers(): array
81
    {
82
        return [
83
            'faker' => $this->faker,
84
            'loader' => $this->loader,
85
            'validator' => $this->validator,
86
        ];
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     */
92
    public function getFakerWorker(): FakerWorkerInterface
93
    {
94
        return $this->faker;
95
    }
96
97
    /**
98
     * {@inheritDoc}
99
     */
100
    public function getLoaderWorker(): LoaderWorkerInterface
101
    {
102
        return $this->loader;
103
    }
104
105
    /**
106
     * {@inheritDoc}
107
     */
108
    public function getValidatorWorker(): ValidatorWorkerInterface
109
    {
110
        return $this->validator;
111
    }
112
}
113