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

SlugModel   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A isUnique() 0 11 1
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
}