InputActionTrait::getTextResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Adventure\InputActions;
4
5
use App\Adventure\Location;
6
use App\Adventure\ActionResponses\LocationResponseInterface;
7
8
/**
9
 * The InputActionTrait provides common functionality for input actions in the game.
10
 */
11
trait InputActionTrait
12
{
13
    /**
14
     * @var string The text response for the input action.
15
     */
16
    private $textResponse;
17
18
    /**
19
     * @var LocationResponseInterface|null The location response object for the input action.
20
     */
21
    private $locationResponse;
22
23
    /**
24
     * @var Location|null The location required for the action to work.
25
     */
26
    private $requiredLocation;
27
28
    /**
29
     * InputAction constructor.
30
     *
31
     * @param string $textResponse The text response for the input action.
32
     */
33 5
    public function __construct(string $textResponse)
34
    {
35 5
        $this->textResponse = $textResponse;
36 5
        $this->locationResponse = null;
37 5
        $this->requiredLocation = null;
38
    }
39
40
    /**
41
     * Retrieves the text response for the input action.
42
     *
43
     * @return string The text response.
44
     */
45 1
    public function getTextResponse(): string
46
    {
47 1
        return $this->textResponse;
48
    }
49
50
    /**
51
     * Sets the location response object for the input action.
52
     *
53
     * @param LocationResponseInterface|null $locationResponseObject The location response object, or null.
54
     */
55 2
    public function setLocationResponse(?LocationResponseInterface $locationResponseObject): void
56
    {
57 2
        $this->locationResponse = $locationResponseObject;
58
    }
59
60
    /**
61
     * Retrieves the location response object for the input action.
62
     *
63
     * @return LocationResponseInterface|null The location response object, or null if not set.
64
     */
65 2
    public function getLocationResponse(): ?LocationResponseInterface
66
    {
67 2
        return $this->locationResponse;
68
    }
69
70
    /**
71
     * Sets the location required for the action to work.
72
     *
73
     * @param Location|null $location The required location, or null.
74
     */
75 2
    public function setRequiredLocation(?Location $location): void
76
    {
77 2
        $this->requiredLocation = $location;
78
    }
79
80
    /**
81
     * Retrieves the location required for the action to work.
82
     *
83
     * @return Location|null The required location, or null if not set.
84
     */
85 2
    public function getRequiredLocation(): ?Location
86
    {
87 2
        return $this->requiredLocation;
88
    }
89
}
90