HelloController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 28
ccs 0
cts 23
cp 0
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 3 1
A actionJob() 0 5 1
A actionMail() 0 14 2
1
<?php
2
namespace App\Console\Controller;
3
4
use App\Console\Job\HelloJob;
5
use Yii;
6
7
class HelloController extends Controller
8
{
9
    public function actionIndex($name = 'World')
10
    {
11
        $this->stdout('Hello ' . $name . PHP_EOL);
12
    }
13
14
    public function actionMail($to, $name = 'Foo')
15
    {
16
        $mailer = Yii::$app->getMailer();
17
        $sent = $mailer->compose('hello', ['name'  => $name])
18
            ->setTo($to)
19
            ->setFrom(Yii::$app->get('settingManager')->get('mailer.username'))
20
            ->setSubject('Hello')
21
            ->send();
22
        if (!$sent) {
23
            $this->stdout('Send failure' . PHP_EOL);
24
            return;
25
        }
26
27
        $this->stdout('Sent successfully' . PHP_EOL);
28
    }
29
30
    public function actionJob($name = 'World')
31
    {
32
        $job = new HelloJob(['name' => $name]);
33
        $id = Yii::$app->get('queue')->push($job);
34
        $this->stdout(HelloJob::class . '#' . $id . PHP_EOL);
35
    }
36
}
37