Test Failed
Push — master ( 10865e...d038e5 )
by Simon
10:06
created

User::setPassword()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Schanihbg\User;
4
5
use \Anax\Database\ActiveRecordModel;
6
7
/**
8
 * A database driven model.
9
 */
10
class User extends ActiveRecordModel
11
{
12
    /**
13
     * @var string $tableName name of the database table.
14
     */
15
    protected $tableName = "User";
16
17
    /**
18
     * Columns in the table.
19
     *
20
     * @var integer $id primary key auto incremented.
21
     */
22
    public $id;
23
    public $acronym;
24
    public $email;
25
    public $password;
26
    public $adminflag;
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
    public function setPassword($password)
40
    {
41
        $this->password = password_hash($password, PASSWORD_DEFAULT);
42
    }
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
    public function verifyPassword($acronym, $password)
54
    {
55
        $this->find("acronym", $acronym);
56
        return password_verify($password, $this->password);
57
    }
58
}
59