Delete   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 20
ccs 0
cts 7
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A assemble() 0 14 2
1
<?php
2
3
namespace Nip\Database\Query;
4
5
/**
6
 * Class Delete
7
 * @package Nip\Database\Query
8
 */
9
class Delete extends AbstractQuery
10
{
11
    /**
12
     * Joins together DELETE, FROM, WHERE, ORDER, and LIMIT parts of SQL query
13
     * @return string
14
     */
15
    public function assemble()
16
    {
17
        $query = "DELETE FROM {$this->getManager()->protect($this->getTable())}";
18
19
        $query .= $this->assembleWhere();
20
21
        $order = $this->parseOrder();
22
        if (!empty($order)) {
23
            $query .= " order by {$order}";
24
        }
25
26
        $query .= $this->assembleLimit();
27
28
        return $query;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $query returns the type string which is incompatible with the return type mandated by Nip\Database\Query\AbstractQuery::assemble() of null.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
29
    }
30
}
31