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.

isTargetingIncludedSegments()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace NotificationChannels\OneSignal;
4
5
use Illuminate\Notifications\Notification;
6
7
class OneSignalPayloadFactory
8
{
9
    /**
10
     * Make a one signal notification payload.
11
     *
12
     * @param mixed $notifiable
13
     * @param \Illuminate\Notifications\Notification $notification
14
     * @param mixed $targeting
15
     *
16
     * @return array
17
     */
18 9
    public static function make($notifiable, Notification $notification, $targeting): array
19
    {
20 9
        $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...
21
22 9
        if (static::isTargetingEmail($targeting)) {
23 1
            $payload['filters'] = collect([['field' => 'email', 'value' => $targeting['email']]]);
24 8
        } elseif (static::isTargetingTags($targeting)) {
25 2
            $array = $targeting['tags'];
26 2
            $res = count($array) == count($array, COUNT_RECURSIVE);
27 2
            if ($res) {
28 1
                $payload['tags'] = collect([$targeting['tags']]);
29
            } else {
30 2
                $payload['tags'] = collect($targeting['tags']);
31
            }
32 6
        } elseif (static::isTargetingIncludedSegments($targeting)) {
33 1
            $payload['included_segments'] = collect($targeting['included_segments']);
34 5
        } elseif (static::isTargetingExcludedSegments($targeting)) {
35 1
            $payload['excluded_segments'] = collect($targeting['excluded_segments']);
36 4
        } elseif (static::isTargetingExternalUserIds($targeting)) {
37 1
            $payload['include_external_user_ids'] = collect($targeting['include_external_user_ids']);
38
        } else {
39 3
            $payload['include_player_ids'] = collect($targeting);
40
        }
41
42 9
        return $payload;
43
    }
44
45
    /**
46
     * @param mixed $targeting
47
     *
48
     * @return bool
49
     */
50 6
    protected static function isTargetingIncludedSegments($targeting)
51
    {
52 6
        return is_array($targeting) && array_key_exists('included_segments', $targeting);
53
    }
54
55
    /**
56
     * @param mixed $targeting
57
     *
58
     * @return bool
59
     */
60 4
    protected static function isTargetingExternalUserIds($targeting)
61
    {
62 4
        return is_array($targeting) && array_key_exists('include_external_user_ids', $targeting);
63
    }
64
65
    /**
66
     * @param mixed $targeting
67
     *
68
     * @return bool
69
     */
70 5
    protected static function isTargetingExcludedSegments($targeting)
71
    {
72 5
        return is_array($targeting) && array_key_exists('excluded_segments', $targeting);
73
    }
74
75
    /**
76
     * @param mixed $targeting
77
     *
78
     * @return bool
79
     */
80 9
    protected static function isTargetingEmail($targeting)
81
    {
82 9
        return is_array($targeting) && array_key_exists('email', $targeting);
83
    }
84
85
    /**
86
     * @param mixed $targeting
87
     *
88
     * @return bool
89
     */
90 8
    protected static function isTargetingTags($targeting)
91
    {
92 8
        return is_array($targeting) && array_key_exists('tags', $targeting);
93
    }
94
}
95