BlogCommentPresenter::commentUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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 BlogCommentPresenter
11
{
12
    /**
13
     * Get the content parsed in HTML.
14
     *
15
     * @return Attribute
16
     *
17
     */
18
    protected function contentMarkdown(): Attribute
19
    {
20
        return Attribute::make(
21
            get: fn () => Markdown::convert($this->content)
22
        );
23
    }
24
25
    /**
26
     * Get the comment url.
27
     *
28
     * @return Attribute
29
     */
30
    protected function commentUrl(): Attribute
31
    {
32
        return Attribute::make(
33
            get: fn () => route('blog.comment.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

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