Passed
Push — develop ( 728d57...c3bbc8 )
by Septianata
05:08
created

Attribute   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 1
b 0
f 0
dl 0
loc 29
ccs 7
cts 8
cp 0.875
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getIdentitycardImageAttribute() 0 7 2
A getGoogleMapUrlAttribute() 0 7 3
1
<?php
2
3
namespace App\Models\Concerns\Customer;
4
5
use Illuminate\Support\Facades\Storage;
6
7
/**
8
 * @property string $telegram_chat_id
9
 * @property string $username
10
 * @property string $fullname
11
 * @property \App\Enum\Gender $gender
12
 * @property string $email
13
 * @property string $phone_country
14
 * @property \Propaganistas\LaravelPhone\PhoneNumber $phone
15
 * @property string $whatsapp_phone_country
16
 * @property \Propaganistas\LaravelPhone\PhoneNumber $whatsapp_phone
17
 * @property string $account_number
18
 * @property string $identitycard_number
19
 * @property string $identitycard_image
20
 * @property float|null $location_latitude
21
 * @property float|null $location_longitude
22
 * @property-read string|null $google_map_url
23
 *
24
 * @see \App\Models\Customer
25
 */
26
trait Attribute
27
{
28
    /**
29
     * Return "identitycard_image" attribute value.
30
     *
31
     * @param  mixed  $value
32
     * @return string
33
     */
34 2
    public function getIdentitycardImageAttribute($value): string
35
    {
36 2
        if (is_null($value)) {
37 1
            return asset('img/stisla/avatar/avatar-1.png');
38
        }
39
40 1
        return Storage::url(static::IDENTITYCARD_IMAGE_PATH . '/' . $value);
0 ignored issues
show
Bug introduced by
The constant App\Models\Concerns\Cust...IDENTITYCARD_IMAGE_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
41
    }
42
43
    /**
44
     * Return "google_map_url" attribute value.
45
     *
46
     * @return string|null
47
     */
48 1
    public function getGoogleMapUrlAttribute(): ?string
49
    {
50 1
        if (!is_null($this->location_latitude) && !is_null($this->location_longitude)) {
51 1
            return google_map_url($this->location_latitude, $this->location_longitude);
52
        }
53
54
        return null;
55
    }
56
}
57