Passed
Branch master (e828dd)
by giu
04:12
created

User::_setPassword()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "User.php" doesn't match the expected filename "user.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
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
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in class comment
Loading history...
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
introduced by
The class short comment should describe what the class does and not simply repeat the class name
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
17
class User extends Entity {
0 ignored issues
show
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
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
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 81 characters
Loading history...
24
     * (or remove it), and explicitly make individual fields accessible as needed.
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 82 characters
Loading history...
25
     *
26
     * @var array
27
     */
28
    protected $_accessible = [
0 ignored issues
show
Coding Style introduced by
Protected member variable "_accessible" must not contain a leading underscore
Loading history...
introduced by
Class property $_accessible should use lowerCamel naming without underscores
Loading history...
Coding Style introduced by
Protected member variable _accessible must not be prefixed with an underscore as per coding-style.
Loading history...
29
        '*' => true,
30
        'id' => false
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: false
Loading history...
31
    ];
32
33
    /**
34
     * Fields that are excluded from JSON versions of the entity.
35
     *
36
     * @var array
37
     */
38
    protected $_hidden = [
0 ignored issues
show
Coding Style introduced by
Protected member variable "_hidden" must not contain a leading underscore
Loading history...
introduced by
Class property $_hidden should use lowerCamel naming without underscores
Loading history...
Coding Style introduced by
Protected member variable _hidden must not be prefixed with an underscore as per coding-style.
Loading history...
39
        'password'
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: 'password'
Loading history...
40
    ];
41
42
    // Automatically hash passwords when they are changed.
43
    protected function _setPassword(string $password) {
0 ignored issues
show
Coding Style introduced by
Protected method name "User::_setPassword" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
introduced by
Protected method name "User::_setPassword" is not in lowerCamel format
Loading history...
Coding Style introduced by
Opening brace should be on a new line
Loading history...
44
        $hasher = new DefaultPasswordHasher();
45
        return $hasher->hash($password);
46
    }
47
48
}
49