Passed
Push — master ( e6cccf...74715d )
by Robert
08:36 queued 23s
created

MessagingInfo::getEndTimeAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0625
1
<?php
2
/**
3
 * MessagingInfo
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
13
class MessagingInfo extends Model
14
{
15
	protected $guarded = [];
16
	protected $appends = [
17
		'startTime',
18
		'endTime'
19
	];
20
21 1
	public function getStartTimeAttribute()
22
	{
23 1
		return new Carbon($this->attributes['startTime']);
24
	}
25
	
26 1
	public function getEndTimeAttribute()
27
	{
28 1
		if ($this->attributes['status'] == 'CLOSE') {
29 1
			return new Carbon($this->attributes['endTime']);
30
		} else {
31
			return null;
32
		}
33
	}
34
35 1
	public function getMinutesAttribute()
36
	{
37 1
		return round(($this->attributes['duration'] / 1000) / 60, 2);
38
	}
39
40 1
	public function getSecondsAttribute()
41
	{
42 1
		return $this->attributes['duration'] / 1000;
43
	}
44
45 1
	public function getHoursAttribute()
46
	{
47 1
		return round($this->minutes / 60, 2);
48
	}
49
}
50