Rol::setRol()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
namespace src;
3
4
use src\excepciones\ElRolNoPuedeEstarVacioException;
5
6
class Rol
7
{
8
    private string $_rol;
9
10 14
    public function __construct(string $rol)
11
    {
12 14
        $this->_rol = $this->setRol($rol);
13 14
    }
14
15 14
    public function rol(): string
16
    {
17 14
        return $this->_rol;
18
    }
19
20 14
    private function setRol(string $string): string
21
    {
22 14
        $this->estaVacio($string);
23
24 14
        return $string;
25
    }
26
27 14
    private function estaVacio(string $rol): void
28
    {
29 14
        if (empty($rol)) {
30 1
            throw new ElRolNoPuedeEstarVacioException("El Rol no puede estar vacío");
31
        }
32 14
    }
33
}
34