Completed
Push — master ( 9f6466...621974 )
by Freek
02:29 queued 58s
created

HealthCheck   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
checkHealth() 0 1 ?
A name() 0 4 1
A fail() 0 4 1
A failIf() 0 6 2
A failUnless() 0 6 2
1
<?php
2
3
namespace Spatie\Backup\Tasks\Monitor;
4
5
use Illuminate\Support\Str;
6
use Spatie\Backup\Exceptions\InvalidHealthCheck;
7
use Spatie\Backup\BackupDestination\BackupDestination;
8
9
abstract class HealthCheck
10
{
11
    abstract public function checkHealth(BackupDestination $backupDestination);
12
13
    public function name()
14
    {
15
        return Str::title(class_basename($this));
16
    }
17
18
    protected function fail(string $message)
19
    {
20
        throw InvalidHealthCheck::because($message);
21
    }
22
23
    protected function failIf(bool $condition, string $message)
24
    {
25
        if ($condition) {
26
            $this->fail($message);
27
        }
28
    }
29
30
    protected function failUnless(bool $condition, string $message)
31
    {
32
        if (! $condition) {
33
            $this->fail($message);
34
        }
35
    }
36
}
37