ExtendedDatabaseNotification   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 12
c 2
b 1
f 0
dl 0
loc 29
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loan() 0 4 1
A humanReadableType() 0 9 3
A getUrlAttribute() 0 3 1
1
<?php
2
3
namespace App\Notifications;
4
5
use App\Loan;
6
use Illuminate\Notifications\DatabaseNotification;
7
8
class ExtendedDatabaseNotification extends DatabaseNotification
9
{
10
    public function loan()
11
    {
12
        return $this->belongsTo(Loan::class)
13
            ->withTrashed();
14
    }
15
16
    /**
17
     * The accessors to append to the model's array form.
18
     *
19
     * @var array
20
     */
21
    protected $appends = ['url'];
22
23
    public function getUrlAttribute()
24
    {
25
        return action('NotificationsController@show', $this->id);
26
    }
27
28
    public function humanReadableType()
29
    {
30
        switch ($this->type) {
0 ignored issues
show
Bug introduced by
The property type does not seem to exist on App\Notifications\ExtendedDatabaseNotification. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
31
            case ManualReminder::class:
32
                return 'Manuell påminnelse';
33
            case FirstReminder::class:
34
                return 'Automatisk påminnelse';
35
            default:
36
                return 'Påminnelse';
37
        }
38
    }
39
}
40