Job::confirm()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.9
c 0
b 0
f 0
cc 4
nc 2
nop 1
crap 4
1
<?php
2
3
namespace Basis;
4
5
use Exception;
6
7
abstract class Job
8
{
9
    use Toolkit;
10
11 4
    protected function require($name)
12
    {
13 4
        if (!$this->$name) {
14
            throw new Exception("$name is not defined");
15
        }
16 4
    }
17
18 1
    protected function confirm($message)
19
    {
20 1
        $hash = md5($message);
21 1
        if (!property_exists($this, '_confirmations') || !is_array($this->_confirmations) || !in_array($hash, $this->_confirmations)) {
0 ignored issues
show
Bug introduced by
The property _confirmations 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...
22 1
            throw new Exception(json_encode([
23 1
                'type' => 'confirm',
24 1
                'message' => $message,
25 1
                'hash' => $hash
26
            ]));
27
        }
28 1
    }
29
}
30