DeleteQuery::__construct()   A
last analyzed

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
use Wandu\Database\Support\Helper;
7
8
class DeleteQuery extends HasWhereExpression implements QueryInterface
9
{
10
    /** @var string */
11
    protected $table;
12
13
    /**
14
     * @param string $table
15
     */
16 2
    public function __construct($table)
17
    {
18 2
        $this->table = $table;
19 2
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 2
    public function toSql()
25
    {
26 2
        $parts = ['DELETE FROM ' . Helper::normalizeName($this->table)];
27 2
        if ($part = parent::toSql()) {
28 2
            $parts[] = $part;
29
        }
30 2
        return implode(' ', $parts);
31
    }
32
}
33