Passed
Branch master (ac8b07)
by Robert
03:36
created

Conversation::__construct()   D

Complexity

Conditions 8
Paths 128

Size

Total Lines 30
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 0
cts 16
cp 0
rs 4.6666
c 0
b 0
f 0
cc 8
eloc 15
nc 128
nop 1
crap 72
1
<?php
2
3
namespace LivePersonInc\LiveEngageLaravel\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use LivePersonInc\LiveEngageLaravel\Collections\AgentParticipants;
7
use LivePersonInc\LiveEngageLaravel\Collections\ConsumerParticipants;
8
use LivePersonInc\LiveEngageLaravel\Collections\Transfers;
9
use LivePersonInc\LiveEngageLaravel\Collections\Transcript;
10
11
class Conversation extends Model
12
{
13
	protected $guarded = [];
14
	
15
	public function __construct(array $item)
16
	{
17
		if (isset($item['info'])) {
18
			$item['info'] = new MessagingInfo((array) $item['info']);
19
		}
20
21
		if (isset($item['visitorInfo'])) {
22
			$item['visitorInfo'] = new Visitor((array) $item['visitorInfo']);
23
		}
24
25
		if (isset($item['campaign'])) {
26
			$item['campaign'] = new Campaign((array) $item['campaign']);
27
		}
28
		
29
		if (isset($item['transfers'])) {
30
			$item['transfers'] = new Transfers((array) $item['transfers']);
31
		}
32
		
33
		if (isset($item['agentParticipants'])) {
34
			$item['agentParticipants'] = new AgentParticipants($item['agentParticipants']);
35
		}
36
		
37
		if (isset($item['consumerParticipants'])) {
38
			$item['consumerParticipants'] = new AgentParticipants($item['consumerParticipants']);
39
		}
40
		
41
		if (isset($item['messageRecords'])) {
42
			$item['messageRecords'] = new Transcript($item['messageRecords']);
43
		}
44
		parent::__construct($item);
45
	}
46
}
47