| Total Complexity | 5 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 4 | trait ArticlePresenter |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * The default banner used when there is no banner for the article. |
||
| 8 | * |
||
| 9 | * @var string |
||
| 10 | */ |
||
| 11 | protected $defaultBanner = '/images/articles/default_banner.jpg'; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Get the article url. |
||
| 15 | * |
||
| 16 | * @return string |
||
| 17 | */ |
||
| 18 | public function getArticleUrlAttribute(): string |
||
| 19 | { |
||
| 20 | if (!isset($this->slug)) { |
||
| 21 | return ''; |
||
| 22 | } |
||
| 23 | |||
| 24 | return route('blog.article.show', ['slug' => $this->slug, 'id' => $this->getKey()]); |
||
|
|
|||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Get the small avatar. |
||
| 29 | * |
||
| 30 | * @return string |
||
| 31 | */ |
||
| 32 | public function getArticleBannerAttribute(): string |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Parse a media and return it if isset or return the default banner. |
||
| 39 | * |
||
| 40 | * @param string $type The type of the media to get. |
||
| 41 | * |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | protected function parseMedia(string $type): string |
||
| 53 |