User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 47
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setPassword() 0 3 1
A verifyPassword() 0 4 1
1
<?php
2
namespace Anax\User;
3
4
use Anax\DatabaseActiveRecord\ActiveRecordModel;
5
6
class User extends ActiveRecordModel
7
{
8
    /**
9
    * @var string $tableName name of the database table.
10
    */
11
    protected $tableName = "User";
12
13
    /**
14
    * Columns in the table.
15
    *
16
    * @var integer $id primary key auto incremented.
17
    */
18
    public $id;
19
    public $username;
20
    public $password;
21
    public $created;
22
    public $updated;
23
    public $activity;
24
25
    /**
26
     * A database driven model.
27
     */
28
    /**
29
    * Set the password.
30
    *
31
    * @param string $password the password to use.
32
    *
33
    * @return void
34
    */
35
    public function setPassword($password)
36
    {
37
        $this->password = password_hash($password, PASSWORD_DEFAULT);
38
    }
39
40
    /**
41
    * Verify the acronym and the password, if successful the object contains
42
    * all details from the database row.
43
    *
44
    * @param string $acronym  acronym to check.
45
    * @param string $password the password to use.
46
    *
47
    * @return boolean true if acronym and password matches, else false.
48
    */
49
    public function verifyPassword($username, $password)
50
    {
51
        $this->find("username", $username);
52
        return password_verify($password, $this->password);
53
    }
54
}
55