StageCallbacks   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 40%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
eloc 8
c 2
b 0
f 1
dl 0
loc 36
rs 10
ccs 4
cts 10
cp 0.4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A run() 0 12 2
1
<?php
2
3
namespace Nip\Controllers\Events;
4
5
use Bytic\Scheduler\Runner\Invoker;
0 ignored issues
show
Bug introduced by
The type Bytic\Scheduler\Runner\Invoker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Closure;
7
8
/**
9
 * Class StageCallbacks
10
 * @package Nip\Controllers\Lifecycle
11
 */
12
class StageCallbacks
13
{
14
    /**
15
     * The array of callbacks to be run
16
     *
17
     * @var array
18
     */
19
    protected $callbacks = [];
20
21
    /**
22
     * Register a callback to be called before the operation.
23
     *
24
     * @param Closure $callback
25
     * @return $this
26
     */
27
    public function add(callable $callback)
28
    {
29
        $this->callbacks[] = $callback;
30
        return $this;
31
    }
32
33
    /**
34
     * @return string
35
     */
36 1
    public function run()
37
    {
38 1
        $output = '';
39 1
        foreach ($this->callbacks as $callback) {
40
//            /** @var Closure $callback */
41
//            if ($callback instanceof Closure) {
42
//                $callback = Closure::bind($callback, $this);
43
//            }
44
            // Invoke the callback with buffering enabled
45
            $output .= \call_user_func_array($callback, []);
46
        }
47 1
        return $output;
48
    }
49
}
50