Total Complexity | 12 |
Total Lines | 65 |
Duplicated Lines | 0 % |
Coverage | 96.67% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class Insert implements InsertInterface |
||
8 | { |
||
9 | private $_where; |
||
10 | |||
11 | 7 | public function __construct(array $datos) |
|
12 | { |
||
13 | 7 | $this->_where = $this->setDatos($datos); |
|
14 | 6 | } |
|
15 | |||
16 | 3 | public function sql(): string |
|
17 | { |
||
18 | 3 | return $this->armarConsulta($this->_where); |
|
19 | } |
||
20 | |||
21 | 3 | public function datos(): array |
|
24 | } |
||
25 | |||
26 | 7 | private function setDatos(array $array): array |
|
27 | { |
||
28 | 7 | $this->estaVacio($array); |
|
29 | 6 | $this->columnaVacia($array); |
|
30 | |||
31 | 6 | return $array; |
|
32 | } |
||
33 | |||
34 | 7 | private function estaVacio(array $array): void |
|
35 | { |
||
36 | 7 | if (count($array) == 0) |
|
37 | { |
||
38 | 1 | throw new Exception("Error Processing Request"); |
|
39 | } |
||
40 | 6 | } |
|
41 | |||
42 | 6 | private function columnaVacia(array $array): void |
|
43 | { |
||
44 | 6 | foreach ($array as $key => $value) |
|
45 | { |
||
46 | 6 | if(empty($key)) |
|
47 | { |
||
48 | throw new Exception("Error Processing Request"); |
||
49 | } |
||
50 | } |
||
51 | 6 | } |
|
52 | |||
53 | 3 | private function armarConsulta(array $array): string |
|
72 | } |
||
73 | } |