Total Complexity | 5 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
12 | trait InteractsWithContext |
||
13 | { |
||
14 | /** |
||
15 | * Get channel. |
||
16 | * |
||
17 | * @return Channel |
||
18 | */ |
||
19 | 1 | protected function getChannel(): Channel |
|
20 | { |
||
21 | 1 | return $this->context()->getChannel(); |
|
22 | } |
||
23 | |||
24 | /** |
||
25 | * Get chat. |
||
26 | * |
||
27 | * @return Chat |
||
28 | */ |
||
29 | 1 | protected function getChat(): Chat |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * Get user. |
||
36 | * |
||
37 | * @return User |
||
38 | */ |
||
39 | 1 | protected function getUser(): User |
|
40 | { |
||
41 | 1 | return $this->context()->getUser(); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * Get the whole context or a single value. |
||
46 | * |
||
47 | * @param string|null $key |
||
48 | * @param mixed $default |
||
49 | * |
||
50 | * @return Context|mixed |
||
51 | */ |
||
52 | 5 | protected function context(string $key = null, $default = null) |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Remember value in context. |
||
59 | * |
||
60 | * @param string $key |
||
61 | * @param mixed $value |
||
62 | */ |
||
63 | 1 | protected function remember(string $key, $value): void |
|
66 | 1 | } |
|
67 | } |
||
68 |