Completed
Push — 4.2 ( cdba14 )
by David
03:01
created

UncheckedOrderBy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 23
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOrderBy() 0 4 1
1
<?php
2
3
namespace Mouf\Database\TDBM;
4
5
/**
6
 * Use this object to inject any SQL string in an order by clause in $dao->find methods.
7
 *
8
 * By default, TDBM is conservative and prevents an ORDERBY clause to be anything other than a sort on columns.
9
 * This is done to prevent SQL injections.
10
 *
11
 * If you need to order on an expression, you can wrap your ORDERBY clause in this class.
12
 *
13
 * For instance:
14
 *
15
 * $this->find(null, null, new UncheckedOrderBy('RAND()'));
16
 *
17
 * Note: you understand that arguments passed inside the `UncheckedOrderBy` constructor are NOT protected and
18
 * can be used for an SQL injection based attack. Therefore, you understand that you MUST NOT put input from the user
19
 * in this constructor.
20
 */
21
class UncheckedOrderBy
22
{
23
    /**
24
     * @var string
25
     */
26
    private $orderBy;
27
28
    /**
29
     * @param $orderBy
30
     */
31
    public function __construct(string $orderBy)
32
    {
33
        $this->orderBy = $orderBy;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getOrderBy() : string
40
    {
41
        return $this->orderBy;
42
    }
43
}
44