Test Failed
Push — master ( 8e3065...29b5e3 )
by Magnus
02:11
created

User   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 64
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setPassword() 0 4 1
A verifyPassword() 0 5 1
A getInformation() 0 5 1
A getInformationById() 0 5 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 2017-09-27
6
 * Time: 10:27
7
 */
8
9
namespace Radchasay\User;
10
11
use \Anax\Database\ActiveRecordModel;
12
13
class User extends ActiveRecordModel
14
{
15
16
    /**
17
     * @var string $tableName name of the database table.
18
     */
19
    protected $tableName = "Users";
20
21
    /**
22
     * Columns in the table.
23
     *
24
     * @var integer $id primary key auto incremented.
25
     */
26
    public $id;
27
    public $name;
28
    public $email;
29
    public $age;
30
    public $password;
31
    public $created;
32
    public $updated;
33
    public $deleted;
34
    public $active;
35
36
37
    /**
38
     * Set the password.
39
     *
40
     * @param string $password the password to use.
41
     *
42
     * @return void
43
     */
44
    public function setPassword($password)
45
    {
46
        $this->password = password_hash($password, PASSWORD_DEFAULT);
47
    }
48
49
50
    /**
51
     * Verify the email and the password, if successful the object contains
52
     * all details from the database row.
53
     *
54
     * @param        $email
55
     * @param string $password the password to use.
56
     * @return bool true if email and password matches, else false.
57
     * @internal param string $email email to check.
58
     */
59
    public function verifyPassword($email, $password)
60
    {
61
        $this->find("email", $email);
62
        return password_verify($password, $this->password);
63
    }
64
65
    public function getInformation($email)
66
    {
67
        $res = $this->find("email", $email);
68
        return $res;
69
    }
70
71
    public function getInformationById($id)
72
    {
73
            $res = $this->find("id", $id);
74
            return $res;
75
    }
76
}
77