SesionId   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A id() 0 3 1
A setId() 0 5 1
A __construct() 0 3 1
A estaVacio() 0 4 2
1
<?php
2
namespace src;
3
4
use Exception;
5
6
class SesionId
7
{
8
    private string $_id;
9
10
    public function __construct(string $id)
11
    {
12
        $this->_id = $this->setId($id);
13
    }
14
15
    public function id(): string
16
    {
17
        return $this->_id;
18
    }
19
20
    private function setId(string $string): string
21
    {
22
        $this->estaVacio($string);
23
24
        return $string;
25
    }
26
27
    private function estaVacio(string $string): void
28
    {
29
        if (empty($string)) {
30
            throw new Exception("El ID de sesión no puede estar vacío");
31
        }
32
    }
33
}
34