Passed
Push — master ( b19e1a...9e97df )
by Robert
03:55
created

Message   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 43.75%

Importance

Changes 0
Metric Value
wmc 10
dl 0
loc 38
ccs 7
cts 16
cp 0.4375
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPlainTextAttribute() 0 3 1
A getTextAttribute() 0 8 4
A __toString() 0 8 4
A getTimeAttribute() 0 3 1
1
<?php
2
3
namespace LivePersonInc\LiveEngageLaravel\Models;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Model;
7
8
class Message extends Model
9
{
10
	protected $guarded = [];
11
12
	protected $appends = [
13
		'plaint_text',
14
		'time',
15
	];
16
17
	public function getTextAttribute()
18
	{
19
		if ($this->type == '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...
20
			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...
21
		} elseif ($this->type == 'RICH_CONTENT') {
22
			return 'RICH_CONTENT';
23
		} else {
24
			return isset($this->attributes['text']) ? $this->attributes['text'] : '';
25
		}
26
	}
27
28
	public function getPlainTextAttribute()
29
	{
30
		return strip_tags($this->text);
31
	}
32
33 2
	public function getTimeAttribute()
34
	{
35 2
		return new Carbon($this->attributes['time']);
36
	}
37
38 2
	public function __toString()
39
	{
40 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...
41 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...
42 1
		} elseif ($this->type == 'RICH_CONTENT') {
43
			return 'RICH_CONTENT';
44
		} else {
45 1
			return isset($this->attributes['text']) ? $this->attributes['text'] : '';
46
		}
47
	}
48
}
49