Passed
Push — Showing-Posts ( 35fb9c...71ba54 )
by Stone
01:47
created

SlugModel::isUnique()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 3
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Models;
4
5
use Core\Model;
6
7
class SlugModel extends Model
8
{
9
10
11
    public function isUnique(string $slug, string $table, string $columnName)
12
    {
13
        $slugTbl = $this->getTablePrefix($table);
14
15
        //TODO verify vars
16
17
        $sql = "SELECT * FROM $slugTbl WHERE $columnName = :slug";
18
        $stmt = $this->dbh->prepare($sql);
19
        $stmt->bindValue(':slug', $slug);
20
        $stmt->execute();
21
        return !$stmt->rowCount() > 0;
22
23
    }
24
}