TipoDeContratacion::setTipoDeContratacion()   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 TipoDeContratacion
7
{
8
    private string $_tipoDeContratacion;
9
10
    public function __construct(string $tipoDeConsentratacion)
11
    {
12
        $this->_tipoDeContratacion = $this->setTipoDeContratacion($tipoDeConsentratacion);
13
    }
14
15
    public function tipoDeContratacion(): string
16
    {
17
        return $this->_tipoDeContratacion;
18
    }
19
20
    private function setTipoDeContratacion(string $tipoDeConsentratacion): string
21
    {
22
        if(
23
            $tipoDeConsentratacion == 'Por obra o proyecto' || 
24
            $tipoDeConsentratacion == 'Por tiempo determinado (temporal)' ||
25
            $tipoDeConsentratacion == 'Tiempo indeterminado' || 
26
            $tipoDeConsentratacion == 'Honorarios'
27
        )
28
        {
29
            return $tipoDeConsentratacion;
30
        }
31
32
        throw new Exception("Error en Tipo de Contratación", 1);  
33
    }
34
}