| Total Complexity | 7 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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') { |
|
|
|
|||
| 26 | 1 | return $this->messageData->msg->text; |
|
| 27 | 1 | } elseif ($this->type == 'RICH_CONTENT') { |
|
| 28 | return 'RICH_CONTENT'; // @codeCoverageIgnore |
||
| 29 | } else { |
||
| 30 | 1 | return isset($this->attributes['text']) ? $this->attributes['text'] : ''; |
|
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | public function getPlainTextAttribute() |
|
| 35 | { |
||
| 36 | 1 | 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() |
|
| 47 | } |
||
| 48 | } |
||
| 49 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.