Flash::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
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