MailJob   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 29
ccs 0
cts 13
cp 0
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 9 2
A run() 0 4 1
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