WordDto   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 31
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A language() 0 3 1
A word() 0 3 1
A jsonSerialize() 0 7 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Dictionary\Features\WordsFinder\Word;
6
7
use JsonSerializable;
8
9
/**
10
 * @psalm-immutable
11
 */
12
final class WordDto implements JsonSerializable
13
{
14
    private Word $word;
15
    private string $language;
16
17
    public function __construct(string $language, Word $word)
18
    {
19
        $this->word = $word;
20
        $this->language = $language;
21
    }
22
23
    public function language(): string
24
    {
25
        return $this->language;
26
    }
27
28
    public function word(): Word
29
    {
30
        return $this->word;
31
    }
32
33
    /**
34
     * @psalm-suppress ImpureFunctionCall
35
     */
36
    public function jsonSerialize(): array
37
    {
38
        return array_merge(
39
            [
40
                'language' => $this->language,
41
            ],
42
            $this->word->jsonSerialize()
43
        );
44
    }
45
}
46