WorkerCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 29
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A actionWork() 0 8 2
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