Completed
Push — master ( c54dd1...7d6afc )
by Douglas
03:28
created

RobotRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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\Infrastructure\Persistence;
12
13
use Reith\ToyRobot\Domain\Robot\RobotRepositoryInterface;
14
use Reith\ToyRobot\Domain\Robot\RobotFinderInterface;
15
use Reith\ToyRobot\Domain\Robot\Robot;
16
17
class RobotRepository implements RobotRepositoryInterface, RobotFinderInterface
18
{
19
    private $store;
20
21
    /**
22
     * @param RobotStoreInterface $file
0 ignored issues
show
Bug introduced by
There is no parameter named $file. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
23
     */
24 1
    public function __construct(RobotStoreInterface $store)
25
    {
26 1
        $this->store = $store;
27 1
    }
28
29
    /**
30
     * @return Robot|null
31
     */
32 1
    public function load(): ?Robot
33
    {
34 1
        return $this->store->getRobot();
35
    }
36
37
    /**
38
     * @param Robot $robot
39
     */
40
    public function save(Robot $robot): void
41
    {
42
        $this->store->saveRobot($robot);
43
    }
44
45
    /**
46
     * Implemented for the RobotFinderInterface
47
     *
48
     * @return Robot[]
49
     */
50
    public function find(): array
51
    {
52
        return [$this->load()];
53
    }
54
}
55