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