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

Orden   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A parametro() 0 3 1
A setOrden() 0 10 2
A alfaNumerico() 0 5 2
1
<?php
2
namespace src\pdodatabase\elementos;
3
4
use Exception;
5
6
class Orden
7
{
8
    private $_orden;
9
10
    public function __construct(string $Orden)
11
    {
12
        $this->_orden = $this->setOrden($Orden);
13
    }
14
15
    public function parametro(): string
16
    {
17
        return $this->_orden;
18
    }
19
20
    private function setOrden(string $orden): string
21
    {
22
        if(empty($orden))
23
        {
24
            throw new Exception("La sentencia ORDEN BY no puede estar vacia"); 
25
        }
26
27
        $this->alfaNumerico($orden);
28
29
        return ' ORDER BY '.$orden;
30
    }
31
32
    private function alfaNumerico($string)
33
    {
34
        if(!ctype_alnum($string))
35
        {
36
            throw new Exception("Caracter invalido en el campo de la sentencia ORDEN BY");
37
        }
38
    }
39
}