User::verifyPassword()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Lyco\User;
4
5
use Anax\DatabaseActiveRecord\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 $password;
25
    public $info;
26
    /**
27
     * Set the password.
28
     *
29
     * @param string $password the password to use.
30
     *
31
     * @return void
32
     */
33
    public function setPassword($password)
34
    {
35
        $this->password = password_hash($password, PASSWORD_DEFAULT);
36
    }
37
38
39
    /**
40
     * Verify the acronym and the password, if successful the object contains
41
     * all details from the database row.
42
     *
43
     * @param string $acronym  acronym to check.
44
     * @param string $password the password to use.
45
     *
46
     * @return boolean true if acronym and password matches, else false.
47
     */
48
    public function verifyPassword($acronym, $password)
49
    {
50
        $this->find("acronym", $acronym);
51
        return password_verify($password, $this->password);
52
    }
53
}
54