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 (#70)
by
unknown
08:20
created

OneSignalPayloadFactory::isTargetingEmail()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
namespace NotificationChannels\OneSignal;
3
4
use Illuminate\Notifications\Notification;
5
6
class OneSignalPayloadFactory
7
{
8
    /**
9
     * Make a one signal notification payload.
10
     *
11
     * @param mixed $notifiable
12
     * @param \Illuminate\Notifications\Notification $notification
13
     * @param mixed $targeting
14
     *
15
     * @return array
16
     */
17 3
    public static function make($notifiable, Notification $notification, $targeting): array
18
    {
19 3
        $payload = $notification->toOneSignal($notifiable)->toArray();
0 ignored issues
show
Bug introduced by
The method toOneSignal() 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...
20
21 3
        if (static::isTargetingEmail($targeting)) {
22 1
            $payload['filters'] = collect([['field' => 'email', 'value' => $targeting['email']]]);
23 2
        } elseif (static::isTargetingTags($targeting)) {
24 1
            $payload['tags'] = collect([$targeting['tags']]);
25 1
        } elseif (static::isTargetingIncludedSegments($targeting)) {
26
            $payload['included_segments'] = collect($targeting['included_segments']);
27
        } elseif (static::isTargetingExcludedSegments($targeting)) {
0 ignored issues
show
Bug introduced by
The method isTargetingExcludedSegments() does not exist on NotificationChannels\One...OneSignalPayloadFactory. Did you maybe mean isTargetingExludedSegments()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
28
            $payload['excluded_segments'] = collect($targeting['excluded_segments']);
29
        } else {
30
            $payload['include_player_ids'] = collect($targeting);
31
        }
32
        //dd($payload);
33
34 2
        return $payload;
35
    }
36
37
    /**
38
     * @param mixed $targeting
39
     *
40
     * @return bool
41
     */
42 3
    protected static function isTargetingEmail($targeting)
43
    {
44 3
        return is_array($targeting) && array_key_exists('email', $targeting);
45
    }
46
47
    /**
48
     * @param mixed $targeting
49
     *
50
     * @return bool
51
     */
52 2
    protected static function isTargetingTags($targeting)
53
    {
54 2
        return is_array($targeting) && array_key_exists('tags', $targeting);
55
    }
56
57
    /**
58
     * @param mixed $targeting
59
     *
60
     * @return bool
61
     */
62 1
    protected static function isTargetingIncludedSegments($targeting)
63
    {
64 1
        return is_array($targeting) && array_key_exists('included_segments', $targeting);
65
    }
66
67
    /**
68
     * @param mixed $targeting
69
     *
70
     * @return bool
71
     */
72
    protected static function isTargetingExludedSegments($targeting)
73
    {
74
        return is_array($targeting) && array_key_exists('excluded_segments', $targeting);
75
    }
76
}
77