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