LineDto::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Crossword\Features\Constructor;
6
7
use App\Crossword\Features\Constructor\Dictionary\Word;
8
use App\Crossword\Features\Constructor\Scanner\Grid\Line;
9
use JsonSerializable;
10
11
/**
12
 * @psalm-immutable
13
 */
14
final class LineDto implements JsonSerializable
15
{
16
    private Line $line;
17
    private Word $word;
18
19
    public function __construct(Line $line, Word $word)
20
    {
21
        $this->line = $line;
22
        $this->word = $word;
23
    }
24
25
    public function line(): Line
26
    {
27
        return $this->line;
28
    }
29
30
    /**
31
     * @psalm-suppress ImpureMethodCall
32
     */
33
    public function jsonSerialize(): array
34
    {
35
        return [
36
            'line' => $this->line->jsonSerialize(),
37
            'word' => $this->word->jsonSerialize(),
38
        ];
39
    }
40
}
41