MoveLocationResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A doLocationResponse() 0 5 1
1
<?php
2
3
namespace App\Adventure\ActionResponses;
4
5
use App\Adventure\Location;
6
7
/**
8
 * MoveLocationResponse implements the LocationResponseInterface.
9
 * It moves the player to a new location.
10
 */
11
class MoveLocationResponse implements LocationResponseInterface
12
{
13
    /**
14
     * @var Location The new location to move to.
15
     */
16
    private $newLocation;
17
18
    /**
19
     * MoveLocationResponse constructor.
20
     *
21
     * @param Location $newLocation The new location to move to.
22
     */
23 1
    public function __construct(Location $newLocation)
24
    {
25 1
        $this->newLocation = $newLocation;
26
    }
27
28
    /**
29
     * Performs the location response action by returning the new location.
30
     *
31
     * @param  Location|null $oldLocation The current location.
32
     * @return Location The resulting location after the move, will be the new location.
33
     */
34 1
    public function doLocationResponse(?Location $oldLocation): Location
35
    {
36 1
        $resultLocation = $this->newLocation;
37
38 1
        return $resultLocation;
39
    }
40
}
41