Message   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 73.32%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 9
eloc 20
c 4
b 1
f 0
dl 0
loc 44
ccs 11
cts 15
cp 0.7332
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getRichContentAttribute() 0 6 2
A getPlainTextAttribute() 0 3 1
A __toString() 0 3 1
A getTextAttribute() 0 8 4
A getTimeAttribute() 0 3 1
1
<?php
2
/**
3
 * Message
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 Message extends Model
14
{
15
	protected $guarded = [];
16
17
	protected $appends = [
18
		'plain_text',
19
		'text',
20
		'time',
21
		'rich_content'
22
	];
23
	
24 2
	public function getTextAttribute()
25
	{
26 2
		if ($this->type == 'TEXT_PLAIN') {
0 ignored issues
show
Bug introduced by
The property type does not seem to exist on LivePersonInc\LiveEngageLaravel\Models\Message. 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...
27 1
			return $this->messageData->msg->text;
0 ignored issues
show
Bug introduced by
The property messageData does not seem to exist on LivePersonInc\LiveEngageLaravel\Models\Message. 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...
28 1
		} elseif ($this->type == 'RICH_CONTENT') {
29
			return 'RICH_CONTENT'; // @codeCoverageIgnore
30
		} else {
31 1
			return isset($this->attributes['text']) ? $this->attributes['text'] : '';
32
		}
33
	}
34
	
35
	public function getRichContentAttribute()
36
	{
37
		if ($this->type == 'RICH_CONTENT') {
0 ignored issues
show
Bug introduced by
The property type does not seem to exist on LivePersonInc\LiveEngageLaravel\Models\Message. 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...
38
			return json_decode($this->messageData->richContent->content);
0 ignored issues
show
Bug introduced by
The property messageData does not seem to exist on LivePersonInc\LiveEngageLaravel\Models\Message. 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...
39
		} else {
40
			return 'RICH_CONTENT';
41
		}
42
	}
43
44 1
	public function getPlainTextAttribute()
45
	{
46 1
		return strip_tags($this->text);
47
	}
48
49 2
	public function getTimeAttribute()
50
	{
51 2
		return new Carbon($this->attributes['time']);
52
	}
53
54 2
	public function __toString()
55
	{
56 2
		return $this->text;
57
	}
58
}
59