WorkerCommand::actionWork()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace yiicod\mailqueue\commands;
4
5
use yii\console\Controller;
6
use yiicod\mailqueue\components\MailHandler;
7
use yiicod\mailqueue\components\MailHandlerInterface;
8
use yiicod\mailqueue\MailQueue;
9
10
/**
11
 * Console command
12
 * class MailQueueCommand
13
 */
14
class WorkerCommand extends Controller
15
{
16
    /**
17
     * @var MailHandlerInterface
18
     */
19
    public $mailProvider = MailHandler::class;
20
21
    /**
22
     * @var string
23
     */
24
    public $defaultAction = 'work';
25
26
    /**
27
     * @var int
28
     */
29
    public $delay = 15;
30
31
    /**
32
     * @throws \Exception
33
     */
34
    public function actionWork()
35
    {
36
        while (true) {
37
            MailQueue::delivery(new $this->mailProvider());
38
39
            sleep($this->delay);
40
        }
41
    }
42
}
43