Completed
Push — 3.x ( 53c3d5...e5eb1c )
by Paul
04:01 queued 01:43
created

Delete   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 53.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 74
ccs 8
cts 15
cp 0.5333
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A buildFrom() 0 4 1
A buildLimit() 0 4 1
A from() 0 5 1
A build() 0 10 1
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\SqlQuery\Common;
10
11
use Aura\SqlQuery\AbstractDmlQuery;
12
13
/**
14
 *
15
 * An object for DELETE queries.
16
 *
17
 * @package Aura.SqlQuery
18
 *
19
 */
20
class Delete extends AbstractDmlQuery implements DeleteInterface
21
{
22
    use WhereTrait;
23
24
    /**
25
     *
26
     * The table to delete from.
27
     *
28
     * @var string
29
     *
30
     */
31
    protected $from;
32
33
    /**
34
     *
35
     * Sets the table to delete from.
36
     *
37
     * @param string $table The table to delete from.
38
     *
39
     * @return $this
40
     *
41
     */
42 13
    public function from($table)
43
    {
44
        $this->from = $this->quoter->quoteName($table);
45 13
        return $this;
46
    }
47
48
    /**
49
     *
50
     * Builds this query object into a string.
51
     *
52
     * @return string
53
     *
54
     */
55 11
    protected function build()
56
    {
57 11
        return 'DELETE'
58
            . $this->buildFlags()
59
            . $this->buildFrom()
60
            . $this->buildWhere()
61
            . $this->buildOrderBy()
62
            . $this->buildLimit()
63
            . $this->buildReturning();
64
    }
65
66
    /**
67
     *
68
     * Builds the FROM clause.
69
     *
70
     * @return string
71
     *
72
     */
73 11
    protected function buildFrom()
74
    {
75 11
        return " FROM {$this->from}";
76
    }
77
78
    /**
79
     *
80
     * Template method overridden for queries that allow LIMIT and OFFSET.
81
     *
82
     * Builds the `LIMIT ... OFFSET` clause of the statement.
83
     *
84
     * Note that this will allow OFFSET values with a LIMIT.
85
     *
86
     * @return string
87
     *
88
     */
89 4
    protected function buildLimit()
90
    {
91 4
        return '';
92
    }
93
}
94