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

Agent::getCurrentStatusReasonStartTimeAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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
}