Passed
Push — Auth ( 051e33...da6940 )
by Stone
02:32
created

UserModel::isEmailUnique()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Models;
4
5
use Core\Container;
6
use Core\Model;
7
8
class UserModel extends Model
9
{
10
11
    private $userTbl;
12
13
    public function __construct(Container $container)
14
    {
15
        parent::__construct($container);
16
        $this->userTbl = $this->getTablePrefix("users");
17
    }
18
19
    /**
20
     * Get all the data about a user for posts (Author).
21
     * @param int $authorId
22
     * @return array
23
     * @throws \ReflectionException
24
     */
25
    public function getAuthorDetails(int $authorId)
26
    {
27
        return $this->getRowById($authorId);
28
    }
29
30
    public function isEmailUnique(string $email)
31
    {
32
        $sql = "
33
            SELECT * FROM $this->userTbl WHERE email = :email
34
        ";
35
        $this->query($sql);
36
        $this->bind(':email', $email);
37
        $this->execute();
38
39
        return $this->stmt->rowCount() > 0;
40
    }
41
}