Completed
Push — 3.x ( e5eb1c...76cecd )
by Paul
9s
created

Delete::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 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 13
        $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
        return 'DELETE'
58 11
            . $this->builder->buildFlags($this->flags)
0 ignored issues
show
Bug introduced by
The property builder does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
59 11
            . $this->builder->buildFrom($this->from)
60 11
            . $this->builder->buildWhere($this->where)
61 11
            . $this->builder->buildOrderBy($this->order_by);
62
    }
63
}
64