Completed
Push — master ( 4dbd37...a699b3 )
by Sebastian
02:59
created

Check::hasFailed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace phpbu\App\Runner;
3
4
use phpbu\App\Backup\Check as CheckExe;
5
use phpbu\App\Backup\Check\Simulator;
6
use phpbu\App\Backup\Collector;
7
use phpbu\App\Backup\Target;
8
use phpbu\App\Result;
9
10
/**
11
 * Check Runner class.
12
 *
13
 * @package    phpbu
14
 * @subpackage App
15
 * @author     Sebastian Feldmann <[email protected]>
16
 * @copyright  Sebastian Feldmann <[email protected]>
17
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
18
 * @link       http://phpbu.de/
19
 * @since      Class available since Release 3.0.0
20
 */
21
class Check extends Abstraction
22
{
23
    /**
24
     * Executes or simulate backup check.
25
     *
26
     * @param  \phpbu\App\Backup\Check     $check
27
     * @param  \phpbu\App\Backup\Target    $target
28
     * @param  mixed                       $value
29
     * @param  \phpbu\App\Backup\Collector $collector
30
     * @param  \phpbu\App\Result           $result
31
     * @return bool
32
     */
33
    public function run(CheckExe $check, Target $target, $value, Collector $collector, Result $result)
34
    {
35
        return $this->isSimulation()
36
            ? $this->simulate($check, $target, $value, $collector, $result)
37
            : $this->check($check, $target, $value, $collector, $result);
38
    }
39
40 3
    /**
41
     * Execute the backup check.
42
     *
43 3
     * @param  \phpbu\App\Backup\Check     $check
44
     * @param  \phpbu\App\Backup\Target    $target
45 3
     * @param  mixed                       $value
46 1
     * @param  \phpbu\App\Backup\Collector $collector
47 1
     * @param  \phpbu\App\Result           $result
48 1
     * @return bool
49 1
     */
50
    protected function check(CheckExe $check, Target $target, $value, Collector $collector, Result $result)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
51 3
    {
52 1
        return $check->pass($target, $value, $collector, $result);
53 1
    }
54 1
55
    /**
56 3
     * Simulate the backup check.
57
     *
58
     * @param  \phpbu\App\Backup\Check     $check
59
     * @param  \phpbu\App\Backup\Target    $target
60
     * @param  mixed                       $value
61
     * @param  \phpbu\App\Backup\Collector $collector
62
     * @param  \phpbu\App\Result           $result
63 3
     * @return bool
64
     */
65 3
    protected function simulate(CheckExe $check, Target $target, $value, Collector $collector, Result $result)
66
    {
67
        return ($check instanceof Simulator) ? $check->simulate($target, $value, $collector, $result) : true;
68
    }
69
}
70