Passed
Push — dev5a ( 2c238c...96dd50 )
by Ron
07:38
created

CustomerContactPhones   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypeNameAttribute() 0 3 1
A getReadableAttribute() 0 3 1
A getTypeIconAttribute() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class CustomerContactPhones extends Model
8
{
9
    protected $fillable = ['cont_id', 'phone_type_id', 'phone_number', 'extension'];
10
    protected $appends  = ['type_icon', 'type_name', 'readable'];
11
    protected $hidden   = ['created_at', 'updated_at'];
12
13 4
    public function getTypeIconAttribute()
14
    {
15 4
        return PhoneNumberTypes::find($this->phone_type_id)->icon_class;
16
    }
17
18 6
    public function getTypeNameAttribute()
19
    {
20 6
        return PhoneNumberTypes::find($this->phone_type_id)->description;
21
    }
22
23 6
    public function getReadableAttribute()
24
    {
25 6
        return preg_replace('~.*(\d{3})[^\d]*(\d{3})[^\d]*(\d{4}).*~', '($1) $2-$3', $this->phone_number);
26
    }
27
}
28