Passed
Push — main ( 088d44...a78334 )
by Osvaldo
01:57
created

Operador::operadorVacio()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
rs 10
1
<?php
2
namespace src\pdodatabase\elementos;
3
4
use Exception;
5
use src\interfaces\UnidadDeValorInterface;
6
7
class Operador implements UnidadDeValorInterface
8
{
9
    private $_operadoresValidos = [
10
        '=',
11
        '>',
12
        '<',
13
        '>=',
14
        '<=',
15
        '<>',
16
        '!=',
17
        '!<',
18
        '!>',
19
        'LIKE',
20
        'IN',
21
    ];
22
23
    public function __construct(string $operador)
24
    {
25
        $this->operadorVacio($operador);
26
        $this->operadorValido($operador);
27
        $this->_operador = $operador;
0 ignored issues
show
Bug Best Practice introduced by
The property _operador does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28
    }
29
30
    public function valor(): string
31
    {
32
        return $this->_operador;
33
    }
34
35
    private function operadorVacio(string $operador)
36
    {
37
        if(empty($operador))
38
        {
39
            throw new Exception("Operador vacio"); 
40
        }
41
    }
42
43
    private function operadorValido(string $operador)
44
    {
45
        if(!in_array($operador,$this->_operadoresValidos))
46
        {
47
            throw new Exception("Operador no valido"); 
48
        }
49
    }
50
}