Passed
Push — main ( 88fc44...465bfc )
by Osvaldo
01:43
created

ConsultaConSelect::limite()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

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
rs 10
1
<?php
2
namespace src\pdoDataBase\select;
3
4
use src\FactoryClassInterface;
5
6
use src\pdoDatabase\select\{
7
    Select,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, src\pdoDataBase\select\Select. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
8
    Tabla,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, src\pdoDataBase\select\Tabla. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
9
    Campos,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, src\pdoDataBase\select\Campos. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
10
    Donde,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, src\pdoDataBase\select\Donde. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
11
    Entre,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, src\pdoDataBase\select\Entre. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
12
    Limite,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, src\pdoDataBase\select\Limite. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
13
    Orden
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, src\pdoDataBase\select\Orden. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
14
};
15
16
use src\pdoDataBase\consulta\{Consulta, Query, CrearConsulta};
17
18
use src\pdoDataBase\conexion\CrearConexionBaseDeDatos;
19
20
class ConsultaConSelect implements FactoryClassInterface
21
{
22
    public function crear(array $array): Consulta
23
    {
24
        $donde =  new Donde(
25
            new MasDonde($this->masDonde($array)),
26
            $this->donde($array)
27
        );
28
29
        $select = new Select(
30
            new Tabla($array['tabla']),
31
            new Campos($this->campos($array)),
32
            $donde,
33
            new Entre($this->entre($array)),
34
            new Limite($this->limite($array)),
35
            new Orden($this->orden($array))
36
        );
37
38
        $consulta = new CrearConsulta;
39
        $conexion = new CrearConexionBaseDeDatos;
40
41
        return $consulta->crear(array(
42
            $conexion->crear(array()),
43
            'sql' => $select->select(),
44
            'valores' => $donde->datos()
45
        ));
46
    }
47
48
    private function campos(array $array): array
49
    {
50
        if(isset($array['campos']))
51
        {
52
            return $array['campos'];
53
        }
54
55
        return [];
56
    }
57
58
    private function donde($array): array
59
    {
60
        if(isset($array['donde']))
61
        {
62
            return $array['donde'];
63
        }
64
65
        return [];
66
    }
67
68
    private function masDonde($array): array
69
    {
70
        if( is_array($this->donde($array)) && isset($array['masDonde']) )
71
        {
72
            return $array['masDonde'];
73
        }
74
75
        return [];
76
    }
77
78
    private function entre(array $array): array
79
    {
80
        if(isset($array['entre']))
81
        {
82
            return $array['entre'];
83
        }
84
85
        return [];
86
    }
87
88
    private function limite(array $array)
89
    {
90
        if(isset($array['limite']))
91
        {
92
            return $array['limite'];
93
        }
94
    }
95
96
    private function orden(array $array)
97
    {
98
        if(isset($array['orden']))
99
        {
100
            return $array['orden'];
101
        }
102
    }
103
}