Total Complexity | 9 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 73.32% |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
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') { |
|
|
|||
27 | 1 | return $this->messageData->msg->text; |
|
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() |
||
41 | } |
||
42 | } |
||
43 | |||
44 | 1 | public function getPlainTextAttribute() |
|
47 | } |
||
48 | |||
49 | 2 | public function getTimeAttribute() |
|
50 | { |
||
51 | 2 | return new Carbon($this->attributes['time']); |
|
52 | } |
||
53 | |||
54 | 2 | public function __toString() |
|
57 | } |
||
58 | } |
||
59 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.