GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MailmanTransport::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Qodeboy\Mailman\Transport;
4
5
use Swift_Mailer;
6
use Swift_Transport;
7
use Illuminate\Foundation\Application;
8
use Illuminate\Mail\Transport\Transport;
9
use Qodeboy\Mailman\Message\MailmanMimeMessage;
10
11
class MailmanTransport extends Transport
12
{
13
    /**
14
     * Laravel application container.
15
     *
16
     * @var \Illuminate\Foundation\Application
17
     */
18
    private $app;
19
20
    /**
21
     * Create a new Mailman transport instance.
22
     *
23
     * @param \Illuminate\Foundation\Application $app
24
     */
25
    public function __construct(Application $app)
26
    {
27
        $this->app = $app;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function send(\Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
34
    {
35
        $mailmanMessage = new MailmanMimeMessage($message);
0 ignored issues
show
Documentation introduced by
$message is of type object<Swift_Mime_SimpleMessage>, but the function expects a object<Swift_Mime_Message>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36
        $this->beforeSendPerformed($message);
37
38
        // Deny email delivery if environment is not allowed in the config
39
        if (! in_array($this->app->environment(), config('mailman.delivery.environments'))) {
40
            $mailmanMessage->deny();
41
42
            $recipients = array_keys($mailmanMessage->getTo());
43
            $allowedRecipients = config('mailman.delivery.recipients');
44
45
            $recipientsDiff = array_diff($recipients, $allowedRecipients);
46
47
            // If all recipients are allowed to receive emails
48
            // from denied environments - allow email delivery.
49
            if (count($recipientsDiff) === 0) {
50
                $mailmanMessage->allow();
51
            }
52
        } else {
53
            $mailmanMessage->allow();
54
        }
55
56
        if (config('mailman.log.enabled')) {
57
            $logger = app('mailman.logger');
58
            $logger->log($mailmanMessage);
59
        }
60
61
        if ($mailmanMessage->allowed()) {
62
            /** @var Swift_Transport $transport */
63
            $transport = $this->app['swift.transport']->driver(config('mailman.delivery.driver'));
64
65
            with(new Swift_Mailer($transport))->send($mailmanMessage->getSwiftMessage());
66
        }
67
    }
68
}
69