Completed
Push — master ( 12e396...3147c9 )
by Vladimir
03:12
created

Converse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
wmc 3
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Foundation\Commands;
6
7
use FondBot\Conversation\Intent;
8
use FondBot\Events\MessageReceived;
9
use Illuminate\Foundation\Bus\Dispatchable;
10
use FondBot\Contracts\Conversation\Conversable;
11
12
class Converse
13
{
14
    use Dispatchable;
15
16
    private $conversable;
17
    private $messageReceived;
18
19 1
    public function __construct(Conversable $conversable, MessageReceived $messageReceived)
20
    {
21 1
        $this->conversable = $conversable;
22 1
        $this->messageReceived = $messageReceived;
23 1
    }
24
25 1
    public function handle(): void
26
    {
27 1
        if ($this->conversable instanceof Intent) {
28 1
            context()->setIntent($this->conversable)->setInteraction(null);
29
        }
30
31 1
        $this->conversable->handle($this->messageReceived);
32 1
    }
33
}
34