Passed
Push — master ( 4734a7...2b31f1 )
by Robert
05:42
created

Agent   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 39
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatusMinutesAttribute() 0 3 1
A getLastUpdatedTimeAttribute() 0 3 1
A getCurrentStatusReasonStartTimeAttribute() 0 3 1
A getCurrentStatusStartTimeAttribute() 0 3 1
A getAvatarAttribute() 0 3 2
A getUserTypeNameAttribute() 0 4 2
1
<?php
2
/**
3
 * Agent
4
 *
5
 * @package LivePersonInc\LiveEngageLaravel\Models
6
 */
7
8
namespace LivePersonInc\LiveEngageLaravel\Models;
9
10
use Carbon\Carbon;
11
use Illuminate\Database\Eloquent\Model;
12
use LivePersonInc\LiveEngageLaravel\Facades\LiveEngageLaravel as LiveEngage;
13
14
/**
15
 * Agent class.
16
 * 
17
 * @extends Model
18
 */
19
class Agent extends Model
20
{
21
	protected $guarded = [];
22
	
23
	protected $userTypes = [
24
		0 => 'System',
25
		1 => 'Human',
26
		2 => 'Bot'
27
	];
28
	
29
	public function getUserTypeNameAttribute()
30
	{
31
		$typeid = isset($this->attributes['userTypeId']) ? $this->attributes['userTypeId'] : $this->attributes['userType'];
32
		return $this->userTypes[$typeid];
33
	}
34
	
35
	public function getLastUpdatedTimeAttribute()
36
	{
37
		return new Carbon($this->attributes['lastUpdatedTime']);
38
	}
39
	
40
	public function getCurrentStatusStartTimeAttribute()
41
	{
42
		return new Carbon($this->attributes['currentStatusStartTime']);
43
	}
44
	
45
	public function getCurrentStatusReasonStartTimeAttribute()
46
	{
47
		return new Carbon($this->attributes['currentStatusReasonStartTime']);
48
	}
49
	
50
	public function getStatusMinutesAttribute()
51
	{
52
		return ($this->attributes['currentStatusDuration'] / 1000) / 60;
53
	}
54
	
55
	public function getAvatarAttribute()
56
	{
57
		return isset($this->attributes['pictureUrl']) ? $this->attributes['pictureUrl'] : null;
58
	}
59
	
60
}