Completed
Push — master ( 391062...ff47c5 )
by Rasmus
02:37
created

DeleteQuery   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 92.31%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
wmc 5
lcom 1
cbo 1
ccs 12
cts 13
cp 0.9231
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getSQL() 0 19 5
1
<?php
2
3
namespace mindplay\sql\model;
4
5
use mindplay\sql\framework\Driver;
6
use mindplay\sql\framework\TypeProvider;
7
8
/**
9
 * This class represents a DELETE query.
10
 */
11
class DeleteQuery extends ProjectionQuery
12
{
13 1
    public function getSQL()
14
    {
15 1
        $delete = "DELETE FROM " . $this->buildNodes();
16
17 1
        $where = count($this->conditions)
18 1
            ? "\nWHERE " . $this->buildConditions()
19 1
            : ''; // no conditions present
20
21 1
        $order = count($this->order)
22
            ? "\nORDER BY " . $this->buildOrderTerms()
23 1
            : ''; // no order terms
24
25 1
        $limit = $this->limit !== null
26 1
            ? "\nLIMIT {$this->limit}"
27 1
            . ($this->offset !== null ? " OFFSET {$this->offset}" : '')
28 1
            : ''; // no limit or offset
29
30 1
        return "{$delete}{$where}{$order}{$limit}";
31
    }
32
}
33