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

RobotReporter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 37
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A handleReport() 0 12 2
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