WordDefinitionApiGatewayInMemory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
c 0
b 0
f 0
dl 0
loc 21
ccs 0
cts 9
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A search() 0 7 2
A setNext() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Dictionary\Infrastructure\Gateway\InMemory;
6
7
use App\Dictionary\Features\PopulateStorage\Populate\Port\DefinitionNotFoundInApiGateway;
8
use App\Dictionary\Features\PopulateStorage\Populate\Port\WordDefinitionApiGatewayInterface;
9
10
final class WordDefinitionApiGatewayInMemory implements WordDefinitionApiGatewayInterface
11
{
12
    private string $definition;
13
14
    public function __construct(string $definition)
15
    {
16
        $this->definition = $definition;
17
    }
18
19
    public function search(string $word, string $language): string
20
    {
21
        if ('' === $this->definition) {
22
            throw new DefinitionNotFoundInApiGateway($word, $language);
23
        }
24
25
        return $this->definition;
26
    }
27
28
    public function setNext(WordDefinitionApiGatewayInterface $apiGateway): WordDefinitionApiGatewayInterface
29
    {
30
        throw new DefinitionNotFoundInApiGateway('test-word', 'test-language');
31
    }
32
}
33