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.

MailBreadcrumb::getMetadata()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Honeybadger\HoneybadgerLaravel\Breadcrumbs;
4
5
use Illuminate\Mail\Events\MessageSending;
6
use Illuminate\Mail\Events\MessageSent;
7
8
abstract class MailBreadcrumb extends Breadcrumb
9
{
10
    /**
11
     * @param  MessageSending|MessageSent  $event
12
     * @return array
13
     */
14
    protected function getMetadata($event): array
15
    {
16
        return [
17
            'queue' => $event->data['queue'] ?? null,
18
            'replyTo' => $this->extractAddresses($event->message->getReplyTo()),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->extractAddresses(...>message->getReplyTo()) targeting Honeybadger\HoneybadgerL...umb::extractAddresses() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
19
            'to' => $this->extractAddresses($event->message->getTo()),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->extractAddresses($event->message->getTo()) targeting Honeybadger\HoneybadgerL...umb::extractAddresses() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
20
            'cc' => $this->extractAddresses(($event->message->getCc() ?? [])),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->extractAddresses(...ge->getCc() ?? array()) targeting Honeybadger\HoneybadgerL...umb::extractAddresses() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
21
            'bcc' => $this->extractAddresses(($event->message->getBcc() ?? [])),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->extractAddresses(...e->getBcc() ?? array()) targeting Honeybadger\HoneybadgerL...umb::extractAddresses() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
22
            'subject' => $event->message->getSubject(),
23
        ];
24
    }
25
26
    protected function extractAddresses($addresses): ?string
27
    {
28
        if ($addresses == null) {
29
            return null;
30
        }
31
32
        $keys = array_keys($addresses);
33
        if (($keys[0] ?? null) === 0) {
34
            // Symfony < v6 (SwiftMailer) uses an array keyed by email,
35
            // but v6 (Symfony Mailer) uses a list of Address objects
36
            $addresses = collect($addresses)->map->getAddress()->toArray();
37
        } else {
38
            $addresses = $keys;
39
        }
40
41
        return implode(',', $addresses) ?: null;
42
    }
43
}
44