Issues (21)

src/Mail/MailTracker.php (3 issues)

1
<?php
2
3
namespace NotificationTracker\Mail;
4
5
use Illuminate\Mail\Events\MessageSending;
6
use Illuminate\Mail\Events\MessageSent;
7
use Illuminate\Support\Str;
8
use NotificationTracker\Models\TrackedChannel;
9
use NotificationTracker\NotificationTracker;
10
11
class MailTracker
12
{
13 6
    public static function make(...$args): static
14
    {
15 6
        return new static(...$args);
0 ignored issues
show
The call to NotificationTracker\Mail...lTracker::__construct() has too many arguments starting with $args. ( Ignorable by Annotation )

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

15
        return /** @scrutinizer ignore-call */ new static(...$args);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
16
    }
17
18 3
    public function onSending(MessageSending $event)
19
    {
20 3
        $header = $event->message->getHeaders()->get(NotificationTracker::trackHeaderName());
21 3
        if (!$header || !Str::isUuid($header->getBodyAsString())) {
22
            return;
23
        }
24
25
        /** @var TrackedChannel $tracker */
26 3
        $tracker = NotificationTracker::modelClass('channel')::query()->uuid($header->getBodyAsString())->first();
27
28 3
        (new MailConverter($tracker, $event->message))->format();
0 ignored issues
show
The type NotificationTracker\Mail\MailConverter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
    }
30
31 6
    public function onSent(MessageSent $event)
0 ignored issues
show
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

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

31
    public function onSent(/** @scrutinizer ignore-unused */ MessageSent $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        // TODO: maybe get mail ID?
34 6
    }
35
}
36