Message   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 1
b 0
f 0
dl 0
loc 38
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A consume() 0 4 1
A message() 0 3 1
A type() 0 3 1
A wasConsumed() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of web-stack
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Slick\WebStack\Infrastructure\Http\FlashMessage;
13
14
use Slick\WebStack\Infrastructure\Http\FlashMessageInterface;
15
16
/**
17
 * Message
18
 *
19
 * @package Slick\WebStack\Infrastructure\Http\FlashMessage
20
 */
21
final class Message implements FlashMessageInterface
22
{
23
    private bool $consumed = false;
24
25
    public function __construct(
26
        private readonly string $message,
27
        private readonly FlashMessageType $type = FlashMessageType::INFO
28
    ) {
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function type(): FlashMessageType
35
    {
36
        return $this->type;
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function message(): string
43
    {
44
        return $this->message;
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    public function wasConsumed(): bool
51
    {
52
        return $this->consumed;
53
    }
54
55
    public function consume(): self
56
    {
57
        $this->consumed = true;
58
        return $this;
59
    }
60
}
61