Completed
Push — master ( 326b3e...061c53 )
by Freek
09:13
created

BaseNotification::diskName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Backup\Notifications;
4
5
use Illuminate\Notifications\Notification;
6
use Illuminate\Support\Collection;
7
use Spatie\Backup\Helpers\Format;
8
9
abstract class BaseNotification extends Notification
10
{
11
    /**
12
     * Get the notification's delivery channels.
13
     *
14
     * @param  mixed  $notifiable
0 ignored issues
show
Bug introduced by
There is no parameter named $notifiable. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
15
     * @return array
16
     */
17
    public function via()
18
    {
19
        return config('laravel-backup.notifications.notifications.'.static::class);
20
    }
21
22
    public function applicationName(): string
23
    {
24
        return config('app.name');
25
    }
26
27
    public function diskName(): string
28
    {
29
        return $this->backupDestination()->diskName();
30
    }
31
32
    protected function backupDestinationProperties(): Collection
33
    {
34
        $backupDestination = $this->backupDestination();
35
36
        if (! $backupDestination) {
37
            return collect();
38
        }
39
40
        $newestBackup = $backupDestination->newestBackup();
41
        $oldestBackup = $backupDestination->oldestBackup();
42
43
        return collect([
44
            'Application name' => $this->applicationName(),
45
            'Disk' => $backupDestination->diskName(),
46
            'Newest backup size' => $newestBackup ? Format::humanReadableSize($newestBackup->size()) : 'No backups were made yet',
47
            'Amount of backups' => $backupDestination->backups()->count(),
48
            'Total storage used' => Format::humanReadableSize($backupDestination->backups()->size()),
49
            'Newest backup date' => $newestBackup ? $newestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet',
50
            'Oldest backup date' => $oldestBackup ? $oldestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet',
51
        ])->filter();
52
    }
53
54
    /**
55
     * @return \Spatie\Backup\BackupDestination\BackupDestination|null
56
     */
57
    public function backupDestination()
58
    {
59
        if (isset($this->event->backupDestination)) {
60
            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...
61
        }
62
63
        if (isset($this->event->backupDestinationStatus)) {
64
            return $this->event->backupDestinationStatus->getBackupDestination();
65
        }
66
    }
67
}
68