User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A verifyPassword() 0 4 1
A setPassword() 0 3 1
1
<?php
2
3
namespace Seb\User;
4
5
use Anax\DatabaseActiveRecord\ActiveRecordModel;
6
7
/**
8
 * A database driven model.
9
 */
10
class User extends ActiveRecordModel
11
{
12
13
    // public function __construct(ContainerInterface $di)
14
    // {
15
    //     parent::__construct($di);
16
    // }
17
    /**
18
     * @var string $tableName name of the database table.
19
     */
20
    protected $tableName = "User";
21
22
    /**
23
     * Columns in the table.
24
     *
25
     * @var integer $id primary key auto incremented.
26
     */
27
    public $id;
28
    public $acronym;
29
    public $password;
30
    public $country;
31
    public $city;
32
    public $email;
33
    public $score;
34
35
    /**
36
     * Set the password.
37
     *
38
     * @param string $password the password to use.
39
     *
40
     * @return void
41
     */
42 1
    public function setPassword($password)
43
    {
44 1
        $this->password = password_hash($password, PASSWORD_DEFAULT);
45 1
    }
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 1
    public function verifyPassword($acronym, $password)
57
    {
58 1
        $this->find("acronym", $acronym);
59 1
        return password_verify($password, $this->password);
60
    }
61
}
62