User::getNameAttribute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
use Illuminate\Auth\UserTrait;
4
use Illuminate\Auth\UserInterface;
5
use Illuminate\Auth\Reminders\RemindableTrait;
6
use Illuminate\Auth\Reminders\RemindableInterface;
7
8
/**
9
 * User
10
 *
11
 * @property-read mixed $name
12
 * @property integer $id
13
 * @property string $username
14
 * @property string $displayname
15
 * @property string $email
16
 * @property boolean $admin
17
 * @property string $remember_token
18
 * @property \Carbon\Carbon $created_at
19
 * @property \Carbon\Carbon $updated_at
20
 * @method static \Illuminate\Database\Query\Builder|\User whereId($value)
21
 * @method static \Illuminate\Database\Query\Builder|\User whereUsername($value)
22
 * @method static \Illuminate\Database\Query\Builder|\User whereDisplayname($value)
23
 * @method static \Illuminate\Database\Query\Builder|\User whereEmail($value)
24
 * @method static \Illuminate\Database\Query\Builder|\User whereAdmin($value)
25
 * @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value)
26
 * @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value)
27
 * @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value)
28
 */
29
class User extends Eloquent implements UserInterface, RemindableInterface {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
30
31
	use UserTrait, RemindableTrait;
32
33
	/**
34
	 * The database table used by the model.
35
	 *
36
	 * @var string
37
	 */
38
	protected $table = 'users';
39
40
	/**
41
	 * The attributes excluded from the model's JSON form.
42
	 *
43
	 * @var array
44
	 */
45
	protected $hidden = ['password', 'remember_token'];
46
47
	/**
48
	 * Get auth password
49
	 *
50
	 * Overwritten for mozilla persona usage.
51
	 */
52
	public function getAuthPassword() {
53
		return Hash::make('moz:persona');
54
	}
55
56
	/**
57
	 * Get user's preferred name (username or displayname)
58
	 */
59 5
	public function getNameAttribute() {
60 5
		if ($this->displayname) {
61 2
			return $this->displayname;
62
		}
63
64 3
		return $this->username;
65
	}
66
}
67