ShortLink   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 48
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getShortUrlAttribute() 0 3 1
1
<?php
2
3
namespace danielebuso\shortener\Models;
4
5
use DateTime;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Support\Carbon;
8
9
/**
10
 * Model of the table tasks.
11
 *
12
 * @property string id
13
 * @property string url
14
 * @property string short_url
15
 * @property DateTime|Carbon|null not_before
16
 * @property DateTime|Carbon|null expire_at
17
 * @property boolean enabled
18
 * @property DateTime|Carbon|null created_at
19
 * @property DateTime|Carbon|null updated_at
20
 */
21
class ShortLink extends Model
22
{
23
    /**
24
     * The "type" of the auto-incrementing ID.
25
     *
26
     * @var string
27
     */
28
    protected $keyType = 'string';
29
30
    /**
31
     * The table name that has been migrated.
32
     *
33
     * @var array
34
     */
35
    protected $table = 'short_links';
36
37
    /**
38
     * The attributes that are mass assignable.
39
     *
40
     * @var array
41
     */
42
    protected $fillable = [
43
        'id',
44
        'url',
45
        'not_before',
46
        'expire_at',
47
        'enabled',
48
    ];
49
50
    /**
51
     * The attributes that should be cast to native types.
52
     *
53
     * @var array
54
     */
55
    protected $casts = [
56
        'not_before' => 'datetime',
57
        'expire_at' => 'datetime',
58
    ];
59
60
    /**
61
     * Generate short link url using route
62
     *
63
     * @return string
64
     */
65
    public function getShortUrlAttribute() {
66
        return route('short_link', [$this->id]);
67
    }
68
}
69