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

DeleteMethod   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 32
loc 32
wmc 5
lcom 1
cbo 1
ccs 0
cts 9
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 11 11 2
factory() 1 1 ?
cloneWith() 1 1 ?

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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