Test Failed
Push — master ( 85ca69...144c12 )
by Roman
15:41
created

Word::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Crossword\Domain\Model;
6
7
use JsonSerializable;
8
9
/**
10
 * @psalm-immutable
11
 */
12
final class Word implements JsonSerializable
13
{
14
    private string $value;
15
    private string $definition;
16
17
    public function __construct(string $value, string $definition)
18
    {
19
        $this->value = $value;
20
        $this->definition = $definition;
21
    }
22
23
    public function value(): string
24
    {
25
        return $this->value;
26
    }
27
28
    public function definition(): string
29
    {
30
        return $this->definition;
31
    }
32
33
    public function length(): int
34
    {
35
        return strlen($this->value);
36
    }
37
38
    public function jsonSerialize(): array
39
    {
40
        return [
41
            'word' => $this->value,
42
            'definition' => $this->definition,
43
            'length' => $this->length(),
44
        ];
45
    }
46
}
47