User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 42
ccs 0
cts 6
cp 0
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 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