NombreColumnaJoin::elStringEstaVacio()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 3
rs 10
1
<?php
2
namespace src\pdodatabase\elementos;
3
4
use Exception;
5
6
class NombreColumnaJoin
7
{
8
    private $_tabla1;
9
    private $_tabla2;
10
11 45
    public function __construct(array $array)
12
    {
13 45
        $this->setDatos($array);
14 42
    }
15
16 14
    public function tabla1(): string
17
    {
18 14
        return $this->_tabla1;
19
    }   
20
21 14
    public function tabla2(): string
22
    {
23 14
        return $this->_tabla2;
24
    }
25
26 45
    private function setDatos(array $array): void
27
    {
28 45
        $this->estaVacioElArray($array);
29 44
        $this->elStringEstaVacio($array);
30 43
        $this->tieneMasValores($array);
31
32 42
        if(count($array) == 1)
33
        {
34 35
            $this->_tabla1 = $array[0];
35 35
            $this->_tabla2 = $array[0];
36
        }
37
        else
38
        {
39 7
            $this->_tabla1 = $array[0];
40 7
            $this->_tabla2 = $array[1];
41
        } 
42 42
    }
43
    
44 45
    private function estaVacioElArray(array $array): void
45
    {
46 45
        if(count($array) == 0)
47
        {
48 1
            throw new Exception("Error Processing Request");
49
            
50
        }
51 44
    }
52
53 43
    private function tieneMasValores(array $array): void
54
    {
55 43
        if(count($array) > 2)
56
        {
57 1
            throw new Exception("Error Processing Request");
58
            
59
        }
60 42
    }
61
62 44
    private function elStringEstaVacio(array $array): void
63
    {
64 44
        foreach ($array as $value)
65
        {
66 44
            if(empty($value))
67
            {
68 1
                throw new Exception("Error Processing Request");
69
                
70
            }
71
        }
72
    }
73
}