Total Complexity | 12 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 |
|
63 | } |
||
64 | } |
||
65 | } |