User::verifyPassword()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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