DiscussPostPresenter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A contentMarkdown() 0 4 1
A postUrl() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Models\Presenters;
6
7
use GrahamCampbell\Markdown\Facades\Markdown;
8
use Illuminate\Database\Eloquent\Casts\Attribute;
9
10
trait DiscussPostPresenter
11
{
12
    /**
13
     * Get the content parsed in HTML.
14
     *
15
     * @return Attribute
16
     */
17
    protected function contentMarkdown(): Attribute
18
    {
19
        return Attribute::make(
20
            get: fn () => Markdown::convert($this->content)
21
        );
22
    }
23
24
    /**
25
     * Get the post url.
26
     *
27
     * @return Attribute
28
     */
29
    protected function postUrl(): Attribute
30
    {
31
        return Attribute::make(
32
            get: fn () => route('discuss.post.show', ['id' => $this->getKey()])
0 ignored issues
show
Bug introduced by
It seems like getKey() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
            get: fn () => route('discuss.post.show', ['id' => $this->/** @scrutinizer ignore-call */ getKey()])
Loading history...
33
        );
34
    }
35
}
36