Passed
Pull Request — master (#92)
by Fèvre
13:40 queued 08:22
created

ShopCategoryPresenter::getCategoryUrlAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
namespace Xetaravel\Models\Presenters;
3
4
trait ShopCategoryPresenter
5
{
6
    /**
7
     * Get the category url.
8
     *
9
     * @return string
10
     */
11
    public function getCategoryUrlAttribute(): string
12
    {
13
        if (!isset($this->slug)) {
14
            return '';
15
        }
16
17
        return route('shop.category.show', ['slug' => $this->slug, '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

17
        return route('shop.category.show', ['slug' => $this->slug, 'id' => $this->/** @scrutinizer ignore-call */ getKey()]);
Loading history...
18
    }
19
}
20