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

DeleteQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toSql() 0 8 2
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