Completed
Push — master ( 755d2f...4eddf0 )
by Christopher
05:22
created

DeleteMethod::delete()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 11
loc 11
ccs 0
cts 9
cp 0
rs 9.4286
cc 2
eloc 6
nc 2
nop 0
crap 6
1
<?php
2
3
namespace AsyncPHP\Icicle\Database\Builder\Method;
4
5
use Aura\SqlQuery\QueryFactory;
6
use Aura\SqlQuery\QueryInterface;
7
use LogicException;
8
9
/**
10
 * @property string $table
11
 * @property QueryInterface $query
12
 */
13 View Code Duplication
trait DeleteMethod
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @return static
17
     *
18
     * @throws LogicException
19
     */
20
    public function delete()
21
    {
22
        if (!isset($this->table)) {
23
            throw new LogicException("delete() called before table()");
24
        }
25
26
        $query = $this->factory()->newDelete();
27
        $query->from($this->table);
28
29
        return $this->cloneWith("query", $query);
30
    }
31
32
    /**
33
     * @return QueryFactory
34
     */
35
    abstract protected function factory();
36
37
    /**
38
     * @param string $key
39
     * @param mixed $value
40
     *
41
     * @return static
42
     */
43
    abstract protected function cloneWith($key, $value);
44
}
45