Completed
Push — master ( 8c5d81...eefcd6 )
by Dmitry
02:55
created

src/Job.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Basis;
4
5
use Exception;
6
7
abstract class Job
8
{
9
    use Toolkit;
10
11 1
    protected function require($name)
12
    {
13 1
        if (!$this->$name) {
14
            throw new Exception("$name is not defined");
15
        }
16 1
    }
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
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