DeleteQuery::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @author Jared King <[email protected]>
5
 *
6
 * @link http://jaredtking.com
7
 *
8
 * @copyright 2015 Jared King
9
 * @license MIT
10
 */
11
namespace JAQB\Query;
12
13
use JAQB\Operations\Executable;
14
use JAQB\Statement\FromStatement;
15
use JAQB\Statement\LimitStatement;
16
use JAQB\Statement\OrderStatement;
17
use JAQB\Statement\WhereStatement;
18
use JAQB\Query\Traits\From;
19
use JAQB\Query\Traits\Limit;
20
use JAQB\Query\Traits\OrderBy;
21
use JAQB\Query\Traits\Where;
22
23
class DeleteQuery extends AbstractQuery
24
{
25
    use Executable, From, Limit, OrderBy, Where;
26
27 View Code Duplication
    public function __construct()
28
    {
29
        $this->from = new FromStatement(FromStatement::DELETE);
30
        $this->where = new WhereStatement();
31
        $this->orderBy = new OrderStatement();
32
        $this->limit = new LimitStatement();
33
    }
34
35
    /**
36
     * Generates the raw SQL string for the query.
37
     *
38
     * @return string
39
     */
40
    public function build()
41
    {
42
        $sql = [
43
            $this->from->build(),
44
            $this->where->build(),
45
            $this->orderBy->build(),
46
            $this->limit->build(),
47
        ];
48
49
        $this->values = $this->where->getValues();
50
51
        return implode(' ', array_filter($sql));
52
    }
53
54
    public function __clone()
55
    {
56
        $this->from = clone $this->from;
57
        $this->where = clone $this->where;
58
        $this->orderBy = clone $this->orderBy;
59
        $this->limit = clone $this->limit;
60
    }
61
}
62