Passed
Push — master ( e4ea99...6d7b4b )
by Nícollas
01:12
created

CRUD::delete()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 4
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SimplePHP\Model;
4
5
trait CRUD {
6
    /**
7
     * @param int $primary
8
     * @return null|bool
9
     */
10
    public function delete(int $primary): ?bool
11
    {
12
        try {
13
            $sql = $this->conn->prepare("DELETE FROM {$this->table} WHERE {$this->primary} = :primary");
14
            $sql->bindParam(':primary', $primary);
15
            return $sql->execute();
16
        } catch(PDOException $exception) {
0 ignored issues
show
Bug introduced by
The type SimplePHP\Model\PDOException was not found. Did you mean PDOException? If so, make sure to prefix the type with \.
Loading history...
17
            return null;
18
        }
19
    }
20
}