Passed
Push — dev5 ( b08d9a...c43caf )
by Ron
04:08
created

NewFileUpload   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 27.78%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 44
ccs 5
cts 18
cp 0.2778
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A via() 0 4 1
A toMail() 0 11 1
A toArray() 0 12 1
1
<?php
2
3
namespace App\Notifications;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Notifications\Notification;
7
use Illuminate\Contracts\Queue\ShouldQueue;
8
use Illuminate\Notifications\Messages\MailMessage;
9
10
class NewFileUpload extends Notification implements ShouldQueue
11
{
12
    use Queueable;
13
    protected $details;
14
15
    //  Constructor receives the file link details
16 2
    public function __construct($details)
17
    {
18 2
        $this->details = $details;
19 2
    }
20
21
    //  Notification is sent via email and dashboard notification
22 2
    public function via($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24 2
        return ['mail', 'database'];
25
    }
26
27
    //  Email notification
28
    public function toMail($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30
        return (new MailMessage)
31
            ->line('A new file has been uploaded to the file link - '.$this->details->link_name)
32
            ->action('Click to View Link',
33
                url(route('links.details',
0 ignored issues
show
Bug introduced by
It seems like url(route('links.details...>details->link_name)))) targeting url() can also be of type object<Illuminate\Contracts\Routing\UrlGenerator>; however, Illuminate\Notifications...SimpleMessage::action() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
34
                [
35
                        'id' => $this->details->link_id,
36
                        'name' => urlencode($this->details->link_name)
37
                ])));
38
    }
39
40
    //  Dashboard notification
41
    public function toArray($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        return [
44
            'type'    => 'warning',
45
            'message' => 'New File(s) Uploaded to link - '.$this->details->link_name,
46
            'link'    => url(route('links.details',
47
                            [
48
                            'id' => $this->details->link_id,
49
                                'name' => urlencode($this->details->link_name)
50
                            ]))
51
        ];
52
    }
53
}
54