ValidadorDeParametrosWhereBetween   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 56
ccs 27
cts 27
cp 1
rs 10
wmc 12

7 Methods

Rating   Name   Duplication   Size   Complexity  
A columnaEsString() 0 5 2
A setDatos() 0 8 1
A contieneValoresVacios() 0 7 3
A datos() 0 3 1
A valoresNoSonIguales() 0 5 2
A numeroDeElementosValido() 0 5 2
A __construct() 0 3 1
1
<?php
2
namespace src\pdodatabase\elementos;
3
4
use Exception;
5
use src\interfaces\ValidadorDeParametrosInterface;
6
7
class ValidadorDeParametrosWhereBetween implements ValidadorDeParametrosInterface
8
{
9
    private $_datos;
10
11 32
    public function __construct(array $datos)
12
    {
13 32
        $this->_datos = $this->setDatos($datos);
14 28
    }
15
16 28
    public function datos(): array
17
    {
18 28
        return $this->_datos;
19
    }
20
21 32
    private function setDatos(array $array): array
22
    {
23 32
        $this->numeroDeElementosValido($array);
24 31
        $this->columnaEsString($array);       
25 30
        $this->valoresNoSonIguales($array);
26 29
        $this->contieneValoresVacios($array);
27
28 28
        return $array;
29
    }
30
31 29
    private function contieneValoresVacios($array): void
32
    {
33 29
        foreach ($array as $value)
34
        {
35 29
            if(empty($value))
36
            {
37 1
                throw new Exception("Error Processing Request");
38
            }
39
        }
40 28
    }
41
42 30
    private function valoresNoSonIguales($array): void
43
    {
44 30
        if($array[1] == $array[2])
45
        {
46 1
            throw new Exception("Error Processing Request");
47
        }
48 29
    }
49
50 32
    private function numeroDeElementosValido($array): void
51
    {
52 32
        if(count($array) !== 3)
53
        {
54 1
            throw new Exception("Error Processing Request");
55
        }
56 31
    }
57
58 31
    private function columnaEsString($array): void
59
    {
60 31
        if(!is_string($array[0]))
61
        {
62 1
            throw new Exception("Error Processing Request");
63
        }
64
    }
65
}