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

Delete::marks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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