Passed
Push — main ( a619f1...d1dc3f )
by Osvaldo
05:24
created

NombreColumnaJoin::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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