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 (#28)
by Freek
02:04
created

BaseNotification::getMonitorProperties()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 1
1
<?php
2
3
namespace Spatie\UptimeMonitor\Notifications;
4
5
use Illuminate\Notifications\Notification;
6
7
abstract class BaseNotification extends Notification
8
{
9
    /**
10
     * Get the notification's delivery channels.
11
     *
12
     * @param  mixed  $notifiable
13
     * @return array
14
     */
15
    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...
16
    {
17
        return config('laravel-uptime-monitor.notifications.notifications.'.static::class);
18
    }
19
20
    public function getMonitorProperties($extraProperties = []): array
21
    {
22
        $monitor = $this->event->monitor;
0 ignored issues
show
Bug introduced by
The property event does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23
24
        $properties['location'] = config('laravel-uptime-monitor.notifications.location');
0 ignored issues
show
Coding Style Comprehensibility introduced by
$properties was never initialized. Although not strictly required by PHP, it is generally a good practice to add $properties = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
25
26
        $properties['url'] = (string) $monitor->url;
27
28
        if (! empty($monitor->look_for_string)) {
29
            $properties['look for string'] = $monitor->look_for_string;
30
        }
31
32
        $properties = array_merge($properties, $extraProperties);
33
34
        if ($monitor->check_ssl_certificate) {
35
            $properties['ssl certificate valid'] = $monitor->ssl_certificate_status;
36
            $properties['ssl certificate issuer'] = $monitor->ssl_certificate_issuer;
37
            $properties['ssl certificate expiration date'] = $monitor->formattedSslCertificateExpirationDate;
38
        }
39
40
        return array_filter($properties);
41
    }
42
43
    public function isStillRelevant(): bool
44
    {
45
        return true;
46
    }
47
}
48