Completed
Push — develop ( 3ba432...36e0ad )
by Abdelrahman
01:06
created

HasTranslations   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 3
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAttributeValue() 0 8 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Support\Traits;
6
7
use Spatie\Translatable\HasTranslations as BaseHasTranslations;
8
9
trait HasTranslations
10
{
11
    use BaseHasTranslations;
12
13
    /**
14
     * @param string $key
15
     *
16
     * @return mixed
17
     */
18
    public function getAttributeValue($key)
19
    {
20
        if (! $this->isTranslatableAttribute($key)) {
21
            return parent::getAttributeValue($key);
22
        }
23
24
        return $this->getTranslation($key, config('app.locale')) ?: array_first($this->getTranslations($key));
25
    }
26
}
27