Passed
Branch 1.0 (f7255b)
by Vladimir
06:00
created

InteractsWithContext::getUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Conversation\Traits;
6
7
use FondBot\Drivers\Chat;
8
use FondBot\Drivers\User;
9
use FondBot\Application\Kernel;
10
11
trait InteractsWithContext
12
{
13
    /** @var Kernel */
14
    protected $kernel;
15
16
    /**
17
     * Remember value in context.
18
     *
19
     * @param string $key
20
     * @param        $value
21
     */
22 2
    protected function remember(string $key, $value): void
23
    {
24 2
        $this->kernel->getContext()->setValue($key, $value);
25 2
    }
26
27
    /**
28
     * Get chat.
29
     *
30
     * @return Chat
31
     */
32 1
    protected function getChat(): Chat
33
    {
34 1
        return $this->kernel->getContext()->getChat();
35
    }
36
37
    /**
38
     * Get user.
39
     *
40
     * @return User
41
     */
42 2
    protected function getUser(): User
43
    {
44 2
        return $this->kernel->getContext()->getUser();
45
    }
46
}
47