ApnVoipChannel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 64.29 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 18
loc 28
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A send() 18 18 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 3 View Code Duplication
    public function send($notifiable, Notification $notification)
0 ignored issues
show
Duplication introduced by Chimit
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 3
        $tokens = (array) $notifiable->routeNotificationFor('apn_voip', $notification);
19
20 3
        if (empty($tokens)) {
21
            return;
22
        }
23
24 3
        $message = $notification->toApnVoip($notifiable);
0 ignored issues
show
Bug introduced by Chimit
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 3
        $client = $message->client ?? $this->factory->instance();
27
28 3
        $responses = $this->sendNotifications($client, $message, $tokens);
29
30 3
        $this->dispatchEvents($notifiable, $notification, $responses);
31
32 3
        return $responses;
33
    }
34
}
35