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

Task::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\base\BaseObject;
11
12
/**
13
 * Async task executable.
14
 *
15
 * @author Vuong Minh <[email protected]>
16
 * @since 1.0.0
17
 */
18
abstract class Task extends BaseObject
19
{
20
21
    /**
22
     * Call before run task for setting up environment.
23
     */
24
    abstract public function configure(): void;
25
26
    /**
27
     * Task executable.
28
     *
29
     * @return mixed
30
     */
31
    abstract public function run();
32
33
    /**
34
     * Magic call in child runtime process.
35
     *
36
     * @return mixed result of this task.
37
     * @see [[run()]]
38
     */
39
    public function __invoke()
40
    {
41
        $this->configure();
42
43
        return $this->run();
44
    }
45
46
}
47