Passed
Branch refatoracao (7827b3)
by William
02:24
created

Delete::mountQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Willry\QueryBuilder;
4
5
use Exception;
6
use PDOStatement;
7
use stdClass;
8
9
class Delete extends Base
10
{
11
12
13
    protected function mountQuery(): void
14
    {
15
        $this->query = "DELETE FROM {$this->entity} {$this->where}";
16
    }
17
18
    public function delete(): ?int
19
    {
20
        try {
21
            $this->mountQuery();
22
            $stmt = $this->db->prepare($this->query);
23
            QueryHelpers::bind($stmt, $this->flatBindings());
24
            $stmt->execute();
25
            return $stmt->rowCount() ?? 1;
26
        } catch (\PDOException $exception) {
27
            $this->handleError($exception);
28
        }
29
    }
30
31
}
32