Passed
Push — main ( 884f7a...c1cea3 )
by Osvaldo
05:34
created

Limite::estaVacio()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

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
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
namespace src\pdodatabase\elementos;
3
4
use Exception;
5
use src\interfaces\OrdenOLimiteInterface;
6
7
class Limite implements OrdenOLimiteInterface
8
{
9
    private $_limite;
10
11 3
    public function __construct(string $limite)
12
    {
13 3
        $this->_limite = $this->setOrden($limite);
14 1
    }
15
16 1
    public function sql(): string
17
    {
18 1
        return 'LIMIT '. $this->_limite;
19
    }
20
21 3
    private function setOrden(string $limite): string
22
    {
23 3
        $this->estaVacio($limite);
24 2
        $this->esNumero($limite);
25
26 1
        return $limite;
27
    }
28
29 3
    private function estaVacio(string $limite): void
30
    {
31 3
        if(empty($limite))
32
        {
33 1
            throw new Exception("La sentencia LIMIT no puede estar vacía");
34
            
35
        }
36 2
    }
37
38 2
    private function esNumero(string $limite): void
39
    {
40 2
        if(!is_numeric($limite))
41
        {
42 1
            throw new Exception("El límite solo pueder número en LIMIT");
43
        }
44
    }
45
}