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

Orden::__construct()   A

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