Passed
Push — master ( 16cc4b...9db413 )
by Viktor
01:52
created

MailController::options()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace izumi\spoolmailer;
4
5
use yii\console\Controller;
6
use yii\di\Instance;
7
8
/**
9
 * MailController
10
 *
11
 * @author Viktor Khokhryakov <[email protected]>
12
 */
13
class MailController extends Controller
14
{
15
    public $defaultAction = 'flush';
16
    /**
17
     * @var Mailer|array|string the mailer object or the application component ID of the mailer object.
18
     */
19
    public $mailer = 'mailer';
20
21
    /**
22
     * @inheritdoc
23
     */
24
    public function beforeAction($action)
25
    {
26
        if (!parent::beforeAction($action)) {
27
            return false;
28
        }
29
        $this->mailer = Instance::ensure($this->mailer, Mailer::className());
30
31
        return true;
32
    }
33
34
    /**
35
     * Sends messages.
36
     */
37
    public function actionFlush()
38
    {
39
        $this->mailer->flushQueue();
40
    }
41
}
42