Completed
Push — master ( af3c22...fbabbd )
by Douglas
01:45
created

RobotReporter::handleReport()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * (c) 2018 Douglas Reith.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace Reith\ToyRobot\QueryHandler;
12
13
use Psr\Log\LoggerInterface;
14
use Reith\ToyRobot\Domain\Robot\Robot;
15
use Reith\ToyRobot\Domain\Robot\RobotRepositoryInterface;
16
use Reith\ToyRobot\Messaging\Query\RobotReport;
17
use Reith\ToyRobot\Messaging\Annotation\Subscribe;
18
19
class RobotReporter
20
{
21
    private $robotRepository;
22
23
    private $logger;
24
25
    /**
26
     * @param RobotRepositoryInterface $robotRepository
27
     * @param LoggerInterface          $logger
28
     */
29
    public function __construct(
30
        RobotRepositoryInterface $robotRepository,
31
        LoggerInterface $logger
32
    ) {
33
        $this->robotRepository = $robotRepository;
34
        $this->logger = $logger;
35
    }
36
37
    /**
38
     * @Subscribe
39
     *
40
     * @param RobotReport $query
41
     * @return string
42
     */
43
    public function handleReport(RobotReport $query): string
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        $robot = $this->robotRepository->load();
46
47
        if (!($robot instanceof Robot)) {
48
            throw new \RuntimeException(
49
                'Robot cannot be found'
50
            );
51
        }
52
53
        return 'reporting';
54
    }
55
}
56