GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#103)
by Dwight
07:22
created

ApnVoipChannel::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 21
loc 21
ccs 0
cts 10
cp 0
rs 9.584
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
namespace NotificationChannels\Apn;
4
5
use Illuminate\Notifications\Notification;
6
7
class ApnVoipChannel extends ApnChannel
8
{
9
    /**
10
     * Send the notification to Apple Push Notification Service.
11
     *
12
     * @param mixed $notifiable
13
     * @param \Illuminate\Notifications\Notification $notification
14
     * @return array|void
15
     */
16 View Code Duplication
    public function send($notifiable, Notification $notification)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        $tokens = (array) $notifiable->routeNotificationFor('apn_voip', $notification);
19
20
        if (empty($tokens)) {
21
            return;
22
        }
23
24
        $message = $notification->toApnVoip($notifiable);
0 ignored issues
show
Bug introduced by
The method toApnVoip() does not seem to exist on object<Illuminate\Notifications\Notification>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
26
        $client = $message->client ?? $this->factory->instance();
0 ignored issues
show
Unused Code introduced by
$client is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
27
28
        $responses = $this->sendNotifications(
0 ignored issues
show
Bug introduced by
The call to sendNotifications() misses a required argument $tokens.

This check looks for function calls that miss required arguments.

Loading history...
29
            $message,
30
            $tokens
0 ignored issues
show
Documentation introduced by
$tokens is of type array, but the function expects a object<NotificationChannels\Apn\ApnMessage>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
        );
32
33
        $this->dispatchEvents($notifiable, $notification, $responses);
34
35
        return $responses;
36
    }
37
}
38