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

Word   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 32
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A value() 0 3 1
A length() 0 3 1
A __construct() 0 4 1
A jsonSerialize() 0 6 1
A definition() 0 3 1
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