Passed
Push — master ( 61fa52...b9d74d )
by Vladimir
13:13
created

Intent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 5
dl 0
loc 41
ccs 6
cts 6
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A passesAuthorization() 0 4 1
activators() 0 1 ?
run() 0 1 ?
A handle() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Conversation;
6
7
use FondBot\Bot;
8
use FondBot\Conversation\Traits\Transitions;
9
use FondBot\Conversation\Activators\Activator;
10
use FondBot\Conversation\Traits\Authorization;
11
use FondBot\Conversation\Traits\HasActivators;
12
use FondBot\Conversation\Traits\SendsMessages;
13
use FondBot\Conversation\Traits\InteractsWithContext;
14
15
abstract class Intent implements Conversable
16
{
17
    use InteractsWithContext,
18
        SendsMessages,
19
        Authorization,
20
        HasActivators,
21
        Transitions;
22
23
    /**
24
     * Determine if intent passes the authorization check.
25
     *
26
     * @return bool
27
     */
28 1
    public function passesAuthorization(): bool
29
    {
30 1
        return true;
31
    }
32
33
    /**
34
     * Intent activators.
35
     *
36
     * @return Activator[]
37
     */
38
    abstract public function activators(): array;
39
40
    /**
41
     * Run intent.
42
     */
43
    abstract public function run(): void;
44
45
    /**
46
     * Handle intent.
47
     *
48
     * @param Bot $bot
49
     */
50 2
    public function handle(Bot $bot): void
51
    {
52 2
        $this->bot = $bot;
53 2
        $this->run();
54 2
    }
55
}
56