User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 51
c 1
b 0
f 0
rs 10
wmc 2

2 Methods

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