NombreColumnaJoin   A
last analyzed

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 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
}