Completed
Push — master ( 634a5b...3ee744 )
by Vuong
01:29
created

ChildRuntimeTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 2
cbo 2
dl 0
loc 29
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A run() 0 4 1
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/yii2-async
4
 * @copyright Copyright (c) 2019 Vuong Xuong Minh
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace vxm\async;
9
10
use Yii;
11
12
/**
13
 * Async task executable in child runtime process.
14
 *
15
 * @author Vuong Minh <[email protected]>
16
 * @since 1.0.0
17
 */
18
class ChildRuntimeTask extends Task
19
{
20
    /**
21
     * @var \yii\console\Application|\yii\web\Application for configure environment.
22
     */
23
    public $app;
24
25
    /**
26
     * @var \Spatie\Async\Task|Task|callable task need to run.
27
     */
28
    public $callable;
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function configure(): void
34
    {
35
        Yii::$app = $this->app;
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function run()
42
    {
43
        return call_user_func($this->callable);
44
    }
45
46
}
47