Passed
Push — master ( 2b31f1...52f2c7 )
by Robert
06:09
created

Message   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 34
ccs 9
cts 12
cp 0.75
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A getPlainTextAttribute() 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
	];
22
	
23 2
	public function getTextAttribute()
24
	{
25 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...
26 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...
27 1
		} elseif ($this->type == 'RICH_CONTENT') {
28
			return 'RICH_CONTENT';
29
		} else {
30 1
			return isset($this->attributes['text']) ? $this->attributes['text'] : '';
31
		}
32
	}
33
34
	public function getPlainTextAttribute()
35
	{
36
		return strip_tags($this->text);
37
	}
38
39 2
	public function getTimeAttribute()
40
	{
41 2
		return new Carbon($this->attributes['time']);
42
	}
43
44 2
	public function __toString()
45
	{
46 2
		return $this->text;
47
	}
48
}
49