Flash   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toAssoc() 0 6 1
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jasny\Session\Flash;
6
7
/**
8
 * Flash message.
9
 */
10
class Flash
11
{
12
    public string $type;
13
    public string $message;
14
    public string $contentType;
15
16
    /**
17
     * Flash constructor.
18
     */
19 4
    public function __construct(string $type, string $message, string $contentType)
20
    {
21 4
        $this->type = $type;
22 4
        $this->message = $message;
23 4
        $this->contentType = $contentType;
24 4
    }
25
26
    /**
27
     * Cast to associative array.
28
     *
29
     * @return array{type:string,message:string,contentType:string}
30
     */
31 1
    public function toAssoc(): array
32
    {
33
        return [
34 1
            'type' => $this->type,
35 1
            'message' => $this->message,
36 1
            'contentType' => $this->contentType,
37
        ];
38
    }
39
}
40