Passed
Push — main ( f2df15...8d7bb5 )
by Osvaldo
09:13
created

Limite::setLimite()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
rs 10
1
<?php
2
namespace src\pdodatabase\elementos;
3
4
use Exception;
5
6
class Limite
7
{
8
    private $_limite;
9
10
    public function __construct(string $Limite)
11
    {
12
        $this->_limite = $this->setLimite($Limite);
13
    }
14
15
    public function parametro(): string
16
    {
17
        return $this->_limite;
18
    }
19
20
    private function setLimite(string $limite): string
21
    {
22
        if (empty($limite))
23
        {
24
            throw new Exception("La sentencia LIMITE no puede estar vacia");
25
        }
26
27
        $this->numero($limite);
28
29
        return ' LIMIT '.$limite;
30
    }
31
32
    private function numero($limite)
33
    {
34
        if(!is_numeric($limite))
35
        {
36
            throw new Exception("La sentencia LIMITE solo puede ser número");
37
        }
38
    }
39
}