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
Push — master ( 0941c5...11f95b )
by Freek
02:01
created

BaseNotification::getApplicationName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Spatie\UptimeMonitor\Notifications;
4
5
use Illuminate\Notifications\Notification;
6
use Illuminate\Support\Collection;
7
use Spatie\Backup\BackupDestination\BackupDestination;
8
use Spatie\Backup\Helpers\Format;
9
10
abstract class BaseNotification extends Notification
11
{
12
    /**
13
     * Get the notification's delivery channels.
14
     *
15
     * @param  mixed  $notifiable
16
     * @return array
17
     */
18
    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...
19
    {
20
        return config('laravel-backup.notifications.notifications.'.static::class);
21
    }
22
23
    public function getApplicationName(): string
24
    {
25
        return config('app.name');
26
    }
27
28
    public function getDiskName(): string
29
    {
30
        return $this->getBackupDestination()->getDiskName();
31
    }
32
33
    protected function getBackupDestinationProperties(): Collection
34
    {
35
        $backupDestination = $this->getBackupDestination();
36
37
        if (! $backupDestination) {
38
            return collect();
39
        }
40
41
        $newestBackup = $backupDestination->getNewestBackup();
42
        $oldestBackup = $backupDestination->getOldestBackup();
43
44
        return collect([
45
            'Application name' => $this->getApplicationName(),
46
            'Disk' => $backupDestination->getDiskName(),
47
            'Newest backup size' => $newestBackup ? Format::getHumanReadableSize($newestBackup->size()) : 'No backups were made yet',
48
            'Amount of backups' => $backupDestination->getBackups()->count(),
49
            'Total storage used' => Format::getHumanReadableSize($backupDestination->getBackups()->size()),
50
            'Newest backup date' => $newestBackup ? $newestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet',
51
            'Oldest backup date' => $oldestBackup ? $oldestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet',
52
        ])->filter();
53
    }
54
55
    /**
56
     * @return \Spatie\Backup\BackupDestination\BackupDestination|null
57
     */
58
    public function getBackupDestination()
59
    {
60
        if (isset($this->event->backupDestination)) {
61
            return $this->event->backupDestination;
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...
62
        }
63
64
        if (isset($this->event->backupDestinationStatus)) {
65
            return $this->event->backupDestinationStatus->getBackupDestination();
66
        }
67
    }
68
}
69