MailController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A actionFlush() 0 3 1
1
<?php
2
/**
3
 * @link https://github.com/Izumi-kun/yii2-spoolmailer
4
 * @copyright Copyright (c) 2017 Viktor Khokhryakov
5
 * @license http://opensource.org/licenses/BSD-3-Clause
6
 */
7
8
namespace izumi\spoolmailer;
9
10
use yii\console\Controller;
11
use yii\di\Instance;
12
13
/**
14
 * CLI command for sending spooled messages.
15
 *
16
 * @author Viktor Khokhryakov <[email protected]>
17
 */
18
class MailController extends Controller
19
{
20
    public $defaultAction = 'flush';
21
    /**
22
     * @var Mailer|array|string the mailer object or the application component ID of the mailer object.
23
     */
24
    public $mailer = 'mailer';
25
26
    /**
27
     * @inheritdoc
28
     */
29 1
    public function init()
30
    {
31 1
        parent::init();
32 1
        $this->mailer = Instance::ensure($this->mailer, Mailer::class);
33 1
    }
34
35
    /**
36
     * Sends messages.
37
     */
38 1
    public function actionFlush()
39
    {
40 1
        $this->mailer->flushQueue();
41 1
    }
42
}
43