Passed
Push — main ( c8f39c...1a4746 )
by Osvaldo
02:04
created

columnaEsString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
rs 10
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
    public function __construct(array $datos)
12
    {
13
        $this->_datos = $this->setDatos($datos);
14
    }
15
16
    public function datos(): array
17
    {
18
        return $this->_datos;
19
    }
20
21
    private function setDatos(array $array): array
22
    {
23
        $this->numeroDeElementosValido($array);
24
        $this->columnaEsString($array);       
25
        $this->valoresNoSonIguales($array);
26
        $this->contieneValoresVacios($array);
27
28
        return $array;
29
    }
30
31
    private function contieneValoresVacios($array): void
32
    {
33
        foreach ($array as $value)
34
        {
35
            if(empty($value))
36
            {
37
                throw new Exception("Error Processing Request");
38
            }
39
        }
40
    }
41
42
    private function valoresNoSonIguales($array): void
43
    {
44
        if($array[1] == $array[2])
45
        {
46
            throw new Exception("Error Processing Request");
47
        }
48
    }
49
50
    private function numeroDeElementosValido($array): void
51
    {
52
        if(count($array) !== 3)
53
        {
54
            throw new Exception("Error Processing Request");
55
        }
56
    }
57
58
    private function columnaEsString($array): void
59
    {
60
        if(!is_string($array[0]))
61
        {
62
            throw new Exception("Error Processing Request");
63
        }
64
    }
65
}