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

Message::getPlainTextAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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