Passed
Push — master ( 510a5e...0f9b0c )
by Roman
02:40 queued 14s
created

RecursionJob   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 6 2
1
<?php
2
3
namespace tests\app\jobs;
4
5
use yii\base\BaseObject;
6
use yii\queue\JobInterface;
7
8
/**
9
 * Recursion Job
10
 */
11
class RecursionJob extends BaseObject implements JobInterface
12
{
13
    /**
14
     * @var int
15
     */
16
    public $iterations = 3;
17
    /**
18
     * @var int number of seconds to execute the job.
19
     */
20
    public $timeout = 10;
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function execute($queue)
26
    {
27
        if (--$this->iterations > 0) {
28
            $queue->push($this);
29
        }
30
        sleep($this->timeout);
31
    }
32
}
33