CrosswordDto   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 23
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A withLine() 0 3 1
A jsonSerialize() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Crossword\Features\Constructor;
6
7
use JsonSerializable;
8
9
/**
10
 * @psalm-immutable
11
 */
12
final class CrosswordDto implements JsonSerializable
13
{
14
    /**
15
     * @var LineDto[]
16
     */
17
    private array $lines;
18
19
    public function __construct(LineDto ...$lines)
20
    {
21
        $this->lines = $lines;
22
    }
23
24
    public function withLine(LineDto $line): self
25
    {
26
        return new self($line, ...$this->lines);
27
    }
28
29
    /**
30
     * @psalm-suppress ImpureFunctionCall
31
     */
32
    public function jsonSerialize(): array
33
    {
34
        return array_map(static fn (LineDto $line): array => $line->jsonSerialize(), $this->lines);
35
    }
36
}
37