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

NombreColumnaJoin   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 63
ccs 29
cts 29
cp 1
rs 10
wmc 12

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setDatos() 0 15 2
A tieneMasValores() 0 5 2
A tabla1() 0 3 1
A __construct() 0 3 1
A estaVacioElArray() 0 5 2
A elStringEstaVacio() 0 7 3
A tabla2() 0 3 1
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
}