Passed
Push — main ( 87c1e5...f29b76 )
by William
01:42
created

Delete::delete()   A

Complexity

Conditions 2
Paths 6

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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