Completed
Push — master ( a08399...bacbcd )
by André
01:28
created

User::verifyPassword()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Anax\User;
4
5
use \Anax\Database\ActiveRecordModel;
6
7
/**
8
 * A database driven model.
9
 */
10
class User extends ActiveRecordModel
11
{
12
13
    /**
14
     * @var string $tableName name of the database table.
15
     */
16
    protected $tableName = "Users";
17
18
    /**
19
     * Columns in the table.
20
     *
21
     * @var integer $id primary key auto incremented.
22
     */
23
    public $id;
24
    public $acronym;
25
    public $password;
26
    public $email;
27
    public $created;
28
    public $updated;
29
    public $deleted;
30
    public $active;
31
32
    /**
33
     * Set the password.
34
     *
35
     * @param string $password the password to use.
36
     *
37
     * @return void
38
     */
39 1
    public function setPassword($password)
40
    {
41 1
        $this->password = password_hash($password, PASSWORD_DEFAULT);
42 1
    }
43
44
    /**
45
     * Verify the acronym and the password, if successful the object contains
46
     * all details from the database row.
47
     *
48
     * @param string $acronym  acronym to check.
49
     * @param string $password the password to use.
50
     *
51
     * @return boolean true if acronym and password matches, else false.
52
     */
53 1
    public function verifyPassword($acronym, $password)
54
    {
55 1
        $this->find("acronym", $acronym);
56 1
        return password_verify($password, $this->password);
57
    }
58
}
59