Passed
Push — master ( 26152a...8fe73e )
by F
04:04
created

Type   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getNameAttribute() 0 7 3
A __construct() 0 5 1
1
<?php
2
3
/*
4
 * PWWEB\Localisation\Models\Address\Type Model
5
 *
6
 * Standard Address Type Model.
7
 *
8
 * @author    Frank Pillukeit <[email protected]>
9
 * @copyright 2020 pw-websolutions.com
10
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
11
 */
12
13
namespace PWWEB\Localisation\Models\Address;
14
15
use Illuminate\Database\Eloquent\Model;
16
use PWWEB\Localisation\Contracts\Address\Type as AddressTypeContract;
17
18
class Type extends Model implements AddressTypeContract
19
{
20
    /**
21
     * The attributes that are mass assignable.
22
     *
23
     * @var array
24
     */
25
    protected $fillable = [
26
        'name',
27
    ];
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param array $attributes additional attributes for model initialisation
33
     */
34
    public function __construct(array $attributes = [])
35
    {
36
        parent::__construct($attributes);
37
38
        $this->setTable(config('pwweb.localisation.table_names.address_types'));
39
    }
40
41
    /**
42
     * Obtain the localised name of a country.
43
     *
44
     * @param string $value Original value of the country
45
     *
46
     * @return string
47
     */
48
    public function getNameAttribute($value)
49
    {
50
        if (null === $value || '' === $value) {
51
            return '';
52
        }
53
54
        return __('pwweb::localization.' . $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return __('pwweb::localization.' . $value) also could return the type array which is incompatible with the documented return type string.
Loading history...
55
    }
56
}
57