Passed
Push — master ( e1d963...85ca69 )
by Roman
04:38
created

CrosswordReceiver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 23
ccs 5
cts 9
cp 0.5556
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A receive() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Crossword\Application\Service;
6
7
use App\Crossword\Application\Exception\ReceiveCrosswordException;
8
use App\Crossword\Domain\Repository\ReadCrosswordRepositoryInterface;
9
use Psr\Log\LoggerInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Log\LoggerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Throwable;
11
12
final class CrosswordReceiver
13
{
14
    private LoggerInterface $logger;
15
    private ReadCrosswordRepositoryInterface $readCrosswordRepository;
16
17
    public function __construct(ReadCrosswordRepositoryInterface $readCrosswordRepository, LoggerInterface $logger)
18
    {
19
        $this->logger = $logger;
20
        $this->readCrosswordRepository = $readCrosswordRepository;
21
    }
22
23
    /**
24
     * @throws ReceiveCrosswordException
25
     */
26 2
    public function receive(string $key): array
27
    {
28
        try {
29 2
            return $this->readCrosswordRepository->get($key);
30 1
        } catch (Throwable $exception) {
31 1
            $this->logger->error($exception->getMessage());
32
        }
33
34 1
        throw new ReceiveCrosswordException();
35
    }
36
}
37