Completed
Push — master ( 5bff48...0eeb04 )
by Oscar
02:44
created

Delete   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 33.33 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 9
Bugs 1 Features 0
Metric Value
wmc 2
c 9
b 1
f 0
lcom 0
cbo 4
dl 9
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A __toString() 9 9 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 SimpleCrud\Queries\Mysql;
4
5
use SimpleCrud\Queries\BaseQuery;
6
use SimpleCrud\Queries\SelectionTrait;
7
use SimpleCrud\Entity;
8
use PDOStatement;
9
10
/**
11
 * Manages a database delete query in Mysql databases.
12
 */
13
class Delete extends BaseQuery
14
{
15
    use SelectionTrait;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function __invoke()
21
    {
22
        return $this->entity->getDb()->execute((string) $this, $this->marks);
23
    }
24
25
    /**
26
     * Build and return the query.
27
     *
28
     * @return string
29
     */
30 View Code Duplication
    public function __toString()
0 ignored issues
show
Duplication introduced by
This method 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...
31
    {
32
        $query = "DELETE FROM `{$this->entity->name}`";
33
34
        $query .= $this->whereToString();
35
        $query .= $this->limitToString();
36
37
        return $query;
38
    }
39
}
40