Passed
Push — master ( a2c862...16044f )
by Robert
05:35
created

Conversation   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
eloc 17
dl 0
loc 38
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 12 9
A getExportAttribute() 0 5 1
A getTextTranscriptAttribute() 0 3 1
1
<?php
2
/**
3
 * Conversation
4
 *
5
 * @package LivePersonInc\LiveEngageLaravel\Models
6
 */
7
8
namespace LivePersonInc\LiveEngageLaravel\Models;
9
10
use Illuminate\Database\Eloquent\Model;
11
use LivePersonInc\LiveEngageLaravel\Collections\AgentParticipants;
12
use LivePersonInc\LiveEngageLaravel\Collections\ConsumerParticipants;
13
use LivePersonInc\LiveEngageLaravel\Collections\Transfers;
14
use LivePersonInc\LiveEngageLaravel\Collections\Transcript;
15
use LivePersonInc\LiveEngageLaravel\Collections\SDEs;
16
17
/**
18
 * Conversation class.
19
 * 
20
 * @extends Model
21
 */
22
class Conversation extends Model
23
{
24
	protected $guarded = [];
25
	
26
	protected $appends = [
27
		'textTranscript',
28
	];
29
	
30 2
	public function __construct(array $item)
31
	{
32 2
		$item['info'] = isset($item['info']) ? new MessagingInfo((array) $item['info']) : new MessagingInfo();
33 2
		$item['visitorInfo'] = isset($item['visitorInfo']) ? new Visitor((array) $item['visitorInfo']) : new Visitor();
34 2
		$item['campaign'] = isset($item['campaign']) ? new Campaign((array) $item['campaign']) : new Campaign();
35 2
		$item['transfers'] = new Transfers(isset($item['transfers']) ? $item['transfers'] : []);
36 2
		$item['agentParticipants'] = new AgentParticipants(isset($item['agentParticipants']) ? $item['agentParticipants'] : []);
37 2
		$item['consumerParticipants'] = new ConsumerParticipants(isset($item['consumerParticipants']) ? $item['consumerParticipants'] : []);
38 2
		$item['messageRecords'] = new Transcript(isset($item['messageRecords']) ? $item['messageRecords'] : [], $item['agentParticipants']);
39 2
		$item['sdes'] = new SDEs(isset($item['sdes']->events) ? $item['sdes']->events : []);
40
		
41 2
		parent::__construct($item);
42 2
	}
43
	
44
	/**
45
	 * @codeCoverageIgnore
46
	 */	
47
	public function getTextTranscriptAttribute()
48
	{
49
		return $this->messageRecords->textTranscript();
0 ignored issues
show
Bug introduced by
The property messageRecords does not seem to exist on LivePersonInc\LiveEngage...vel\Models\Conversation. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
50
	}
51
	
52
	/**
53
	 * @codeCoverageIgnore
54
	 */
55
	public function getExportAttribute()
56
	{
57
		$info = $this->info->attributes;
0 ignored issues
show
Bug introduced by
The property info does not seem to exist on LivePersonInc\LiveEngage...vel\Models\Conversation. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
58
		$info['transcript'] = $this->textTranscript;
59
		return ((object)$info);
60
	}
61
}
62