Completed
Push — master ( d778e6...6d1c30 )
by ARCANEDEV
08:16
created

UserPresenter::getFullNameAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
1
<?php namespace Arcanesoft\Auth\Models\Presenters;
2
3
/**
4
 * Class     UserPresenter
5
 *
6
 * @package  Arcanesoft\Auth\Models\Observers
7
 * @author   ARCANEDEV <[email protected]>
8
 *
9
 * @property  string          gravatar
10
 * @property  string          hashed_id
11
 * @property  \Carbon\Carbon  created_at
12
 */
13
trait UserPresenter
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Traits
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    use HasherTrait;
20
21
    /* ------------------------------------------------------------------------------------------------
22
     |  Getters & Setters
23
     | ------------------------------------------------------------------------------------------------
24
     */
25
    /**
26
     * Get the full name attribute or use the username if empty.
27
     *
28
     * @return string
29
     */
30
    public function getFullNameAttribute()
31
    {
32
        $fullName = trim("{$this->first_name} {$this->last_name}");
0 ignored issues
show
Bug introduced by
The property first_name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property last_name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
33
34
        return empty($fullName) ? $this->username : $fullName;
0 ignored issues
show
Bug introduced by
The property username does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
35
    }
36
37
    /**
38
     * Get the since date attribute (translated).
39
     *
40
     * @return string
41
     */
42
    public function getSinceDateAttribute()
43
    {
44
        return trans('auth::users.since', [
45
            'date' => $this->created_at->toFormattedDateString()
46
        ]);
47
    }
48
49
    /**
50
     * Get the gravatar attribute.
51
     *
52
     * @return string
53
     */
54
    public function getGravatarAttribute()
55
    {
56
        return gravatar()
57
            ->setDefaultImage('mm')->setSize(160)
58
            ->src($this->email);
0 ignored issues
show
Bug introduced by
The property email does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
59
    }
60
}
61