Orden::estaVacio()   A
last analyzed

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 Orden implements OrdenOLimiteInterface
8
{
9
    private $_orden;
10
11 41
    public function __construct(string $orden)
12
    {
13 41
        $this->_orden = $this->setOrden($orden);
14 40
    }
15
16 14
    public function sql(): string
17
    {
18 14
        return 'ORDER BY '. $this->_orden;
19
    }
20
21 41
    private function setOrden(string $orden): string
22
    {
23 41
        $this->estaVacio($orden);
24
25 40
        return $orden;
26
    }
27
28 41
    private function estaVacio(string $orden): void
29
    {
30 41
        if(empty($orden))
31
        {
32 1
            throw new Exception("La sentencia ORDER BY no puede estar vacía");
33
            
34
        }
35
    }
36
}