Completed
Push — master ( 1e376d...b0060a )
by Changwan
05:50
created

DeleteQuery::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Database\Query;
3
4
use Wandu\Database\Contracts\QueryInterface;
5
use Wandu\Database\Query\Expression\HasWhereExpression;
6
7
class DeleteQuery extends HasWhereExpression implements QueryInterface
8
{
9
    /** @var string */
10
    protected $table;
11
12
    /**
13
     * @param string $table
14
     */
15 1
    public function __construct($table)
16
    {
17 1
        $this->table = $table;
18 1
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    public function toSql()
24
    {
25 1
        $parts = ['DELETE FROM `' . $this->table . '`'];
26 1
        if ($part = parent::toSql()) {
27 1
            $parts[] = $part;
28 1
        }
29 1
        return implode(' ', $parts);
30
    }
31
}
32