Passed
Branch master (e828dd)
by giu
03:47
created

User   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 29
ccs 0
cts 3
cp 0
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A _setPassword() 0 3 1
1
<?php
2
3
namespace App\Model\Entity;
4
5
use Cake\ORM\Entity;
6
use Authentication\PasswordHasher\DefaultPasswordHasher;
7
8
/**
9
 * User Entity
10
 *
11
 * @property int $id
12
 * @property string $email
13
 * @property string $password
14
 * @property \Cake\I18n\Time $created
15
 * @property \Cake\I18n\Time $modified
16
 */
17
class User extends Entity {
18
19
    /**
20
     * Fields that can be mass assigned using newEntity() or patchEntity().
21
     *
22
     * Note that when '*' is set to true, this allows all unspecified fields to
23
     * be mass assigned. For security purposes, it is advised to set '*' to false
24
     * (or remove it), and explicitly make individual fields accessible as needed.
25
     *
26
     * @var array
27
     */
28
    protected $_accessible = [
29
        '*' => true,
30
        'id' => false
31
    ];
32
33
    /**
34
     * Fields that are excluded from JSON versions of the entity.
35
     *
36
     * @var array
37
     */
38
    protected $_hidden = [
39
        'password'
40
    ];
41
42
    // Automatically hash passwords when they are changed.
43
    protected function _setPassword(string $password) {
44
        $hasher = new DefaultPasswordHasher();
45
        return $hasher->hash($password);
46
    }
47
48
}
49