TipoDeContratacion::tipoDeContratacion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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
}