Completed
Push — master ( 9628d6...a206dc )
by Derek Stephen
09:38
created

User   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 39
rs 10
c 1
b 0
f 0
ccs 2
cts 2
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setPassword() 0 6 1
A verifyPassword() 0 4 1
A toArray() 0 7 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: DM0C60544
5
 * Date: 21/3/2017
6
 * Time: 4:17 PM
7
 */
8
9
namespace OAuth;
10
11
use Del\Entity\User as UserEntity;
12
use OAuth\Traits\EncryptableFieldEntity;
13
14
/**
15
 * @MappedSuperclass(repositoryClass="OAuth\Repository\UserRepository")
16
 */
17
class User extends UserEntity
18
{
19
    use EncryptableFieldEntity;
20
21
    /**
22 1
     * Set password
23
     *
24 1
     * @param string $password
25
     * @return User
26
     */
27
    public function setPassword($password)
28
    {
29
        $password = $this->encryptField($password);
30
        parent::setPassword($password);
31
        return $this;
32
    }
33
34
    /**
35
     * Verify user's password
36
     *
37
     * @param string $password
38
     * @return Boolean
39
     */
40
    public function verifyPassword($password)
41
    {
42
        return $this->verifyEncryptedFieldValue($this->getPassword(), $password);
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function toArray()
49
    {
50
        return [
51
            'user_id' => $this->getID(),
52
            'scope' => null,
53
        ];
54
    }
55
}