MailJob::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
namespace App\Job;
3
4
use App\Queue\Job;
5
use App\Queue\RetryableTrait;
6
use yii\di\Instance;
7
use yii\mail\MailerInterface;
8
use yii\mail\MessageInterface;
9
use yii\queue\RetryableJob;
10
11
class MailJob extends Job implements RetryableJob
0 ignored issues
show
Deprecated Code introduced by
The interface yii\queue\RetryableJob has been deprecated: Will be removed in 3.0. Use RetryableJobInterface instead of RetryableJob. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

11
class MailJob extends Job implements /** @scrutinizer ignore-deprecated */ RetryableJob

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.

Loading history...
12
{
13
    use RetryableTrait;
14
    
15
    /**
16
     * @var string|array|MailerInterface $mailer
17
     */
18
    public $mailer = 'mailer';
19
20
    /**
21
     * @var array $messages
22
     */
23
    public $messages;
24
25
    public function init()
26
    {
27
        parent::init();
28
29
        $this->mailer = Instance::ensure($this->mailer, MailerInterface::class);
30
        foreach ($this->messages as &$message) {
31
            $message = Instance::ensure($message, MessageInterface::class);
32
        }
33
        unset($message);
34
    }
35
36
    protected function run()
37
    {
38
        $sent = $this->mailer->sendMultiple($this->messages);
39
        return $sent;
40
    }
41
}
42