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

UncheckedOrderBy::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 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