TipoDePuesto::setTipoDePuesto()   A
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 13
rs 9.6111
1
<?php
2
namespace src;
3
4
use Exception;
5
6
class TipoDePuesto
7
{
8
    private string $_tipoDePuesto;
9
10
    public function __construct(string $tipoDePuesto)
11
    {
12
        $this->_tipoDePuesto = $this->setTipoDePuesto($tipoDePuesto);
13
    }
14
15
    public function tipoDePuesto(): string
16
    {
17
        return $this->_tipoDePuesto;
18
    }
19
20
    private function setTipoDePuesto(string $tipoDePuesto): string
21
    {
22
        if(
23
            $tipoDePuesto == 'Operativo' || 
24
            $tipoDePuesto == 'Profesional o técnico' ||
25
            $tipoDePuesto == 'Supervisor' || 
26
            $tipoDePuesto == 'Gerente'
27
        )
28
        {
29
            return $tipoDePuesto;
30
        }
31
32
        throw new Exception("Error en Tipo de Puesto", 1);  
33
    }
34
}