User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setPassword() 0 3 1
A verifyPassword() 0 4 1
1
<?php
2
3
namespace Pamo\User;
4
5
use Pamo\MyActiveRecord\MyActiveRecord;
6
7
/**
8
 * A database driven model.
9
 */
10
class User extends MyActiveRecord
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 $username;
24
    public $password;
25
    public $email;
26
    public $rank;
27
    public $voted;
28
29
    /**
30
     * Set the password.
31
     *
32
     * @param string $password the password to use.
33
     *
34
     * @return void
35
     */
36 2
    public function setPassword($password)
37
    {
38 2
        $this->password = password_hash($password, PASSWORD_DEFAULT);
39 2
    }
40
41
    /**
42
     * Verify the acronym and the password, if successful the object contains
43
     * all details from the database row.
44
     *
45
     * @param string $acronym  acronym to check.
46
     * @param string $password the password to use.
47
     *
48
     * @return boolean true if acronym and password matches, else false.
49
     */
50 3
    public function verifyPassword($username, $password)
51
    {
52 3
        $this->find("username", $username);
53 3
        return password_verify($password, $this->password);
54
    }
55
}
56