Passed
Push — v2 ( 7ee84c...a408c1 )
by Daniel
04:52
created

MessageEventListener   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 13
ccs 0
cts 6
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Component Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentBundle\EventListener\Mailer;
15
16
use Symfony\Component\Mailer\Event\MessageEvent;
17
use Symfony\Component\Mime\Address;
18
19
/**
20
 * @author Daniel West <[email protected]>
21
 */
22
class MessageEventListener
23
{
24
    private string $fromEmailAddress;
25
26
    public function __construct(string $fromEmailAddress)
27
    {
28
        $this->fromEmailAddress = $fromEmailAddress;
29
    }
30
31
    public function __invoke(MessageEvent $messageEvent)
32
    {
33
        $message = $messageEvent->getMessage();
34
        $message->from(Address::fromString($this->fromEmailAddress));
0 ignored issues
show
Bug introduced by
The method from() does not exist on Symfony\Component\Mime\RawMessage. It seems like you code against a sub-type of Symfony\Component\Mime\RawMessage such as Symfony\Component\Mime\Email. ( Ignorable by Annotation )

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

34
        $message->/** @scrutinizer ignore-call */ 
35
                  from(Address::fromString($this->fromEmailAddress));
Loading history...
35
    }
36
}
37