HasFullName::getFirstNameName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Angecode\LaravelFullName\Models\Traits;
4
5
use Angecode\LaravelFullName\StrHelper;
6
7
trait HasFullName
8
{
9
    /*protected $fillable = [
10
        'first_name', 'middle_name', 'last_name',
11
    ];*/
12
13
    /*
14
    |--------------------------------------------------------------------------
15
    | ACCESSORS
16
    |--------------------------------------------------------------------------
17
    */
18
19 1
    public function getNameAttribute()
20
    {
21 1
        return StrHelper::implodeFiltered([
22 1
            $this->{$this->getFirstNameName()},
23 1
            $this->{$this->getLastNameName()},
24
        ]);
25
    }
26
27 1
    public function getFullNameAttribute()
28
    {
29 1
        return StrHelper::implodeFiltered([
30 1
            $this->{$this->getFirstNameName()},
31 1
            $this->{$this->getMiddleNameName()},
32 1
            $this->{$this->getLastNameName()},
33
        ]);
34
    }
35
36
    /*
37
    |--------------------------------------------------------------------------
38
    | INTERNAL ACCESSORS
39
    |--------------------------------------------------------------------------
40
    */
41
42 2
    public function getFirstNameName()
43
    {
44 2
        return 'first_name';
45
    }
46
47 2
    public function getMiddleNameName()
48
    {
49 2
        return 'middle_name';
50
    }
51
52 2
    public function getLastNameName()
53
    {
54 2
        return 'last_name';
55
    }
56
}
57