Passed
Pull Request — master (#24)
by Alexander
02:20
created

BeforeSend   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A stopPropagation() 0 3 1
A isPropagationStopped() 0 3 1
A getMessage() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Mailer\Event;
6
7
use Psr\EventDispatcher\StoppableEventInterface;
8
use Yiisoft\Mailer\MessageInterface;
9
10
/**
11
 * BeforeSend event is triggered right before sending the message.
12
 *
13
 * @see \Yiisoft\Mailer\Mailer::beforeSend()
14
 */
15
final class BeforeSend implements StoppableEventInterface
16
{
17
    private MessageInterface $message;
18
    private bool $stopPropagation = false;
19
20 15
    public function __construct(MessageInterface $message)
21
    {
22 15
        $this->message = $message;
23 15
    }
24
25 1
    public function getMessage(): MessageInterface
26
    {
27 1
        return $this->message;
28
    }
29
30 2
    public function stopPropagation(): void
31
    {
32 2
        $this->stopPropagation = true;
33 2
    }
34
35 15
    public function isPropagationStopped(): bool
36
    {
37 15
        return $this->stopPropagation;
38
    }
39
}
40