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

CrosswordReceiver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 2
crap 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