Orden::sql()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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
}