Passed
Pull Request — master (#35)
by Maximilian
03:29
created

CanFulfillIntentResponse::addSlot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Response\CanFulfill;
4
5
/**
6
 * @author Maximilian Beckers <[email protected]>
7
 */
8
class CanFulfillIntentResponse
9
{
10
    const CAN_FULFILL_YES   = 'YES';
11
    const CAN_FULFILL_MAYBE = 'MAYBE';
12
    const CAN_FULFILL_NO    = 'NO';
13
    /**
14
     * @var string|null
15
     */
16
    public $canFulfill;
17
18
    /**
19
     * @var CanFulfillSlot[]
20
     */
21
    public $slots = [];
22
23
    /**
24
     * @param string $canFulfill
25
     * @param array  $slots
26
     *
27
     * @return CanFulfillIntentResponse
28
     */
29
    public static function create(string $canFulfill, array $slots = []): self
30
    {
31
        $canFulfillIntentResponse = new self();
32
33
        $canFulfillIntentResponse->canFulfill = $canFulfill;
34
        $canFulfillIntentResponse->slots      = $slots;
35
36
        return $canFulfillIntentResponse;
37
    }
38
39
    /**
40
     * @param string         $slotName
41
     * @param CanFulfillSlot $canFulfillSlot
42
     */
43
    public function addSlot(string $slotName, CanFulfillSlot $canFulfillSlot)
44
    {
45
        $this->slots[$slotName] = $canFulfillSlot;
46
    }
47
}
48