CrearPersona   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A segundoApellidoExiste() 0 8 2
A crear() 0 10 1
1
<?php
2
namespace src;
3
use src\FactoryClassInterface;
4
5
class CrearPersona implements FactoryClassInterface
6
{   
7
    public function crear(array $array): Persona
8
    {
9
        return new Persona(
10
            new NombreCompleto(
11
                new Nombres($array['nombres']),
12
                new PrimerApellido($array['primerApellido']),
13
                new SegundoApellido($this->segundoApellidoExiste($array))
14
            ),
15
            new FechaDeNacimiento($array['fechaDeNacimiento']),
16
            new Sexo($array['sexo'])
17
        );
18
    }
19
20
    private function segundoApellidoExiste(array $array): string
21
    {
22
        if(!isset($array['segundoApellido']))
23
        {
24
            return '';
25
        }
26
27
        return $array['segundoApellido'];
28
    }
29
}