Passed
Push — master ( 1fb483...35eebd )
by Roman
04:31
created

Word::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
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\Dictionary;
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