Passed
Push — 1.0 ( bc4ae1...82a12a )
by Vladimir
03:01
created

WithPayload   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matches() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Conversation\Activators;
6
7
use FondBot\Drivers\ReceivedMessage;
8
9
class WithPayload implements Activator
10
{
11
    private $value;
12
13 3
    public function __construct(string $value)
14
    {
15 3
        $this->value = $value;
16 3
    }
17
18
    /**
19
     * Result of matching activator.
20
     *
21
     * @param ReceivedMessage $message
22
     *
23
     * @return bool
24
     */
25 2
    public function matches(ReceivedMessage $message): bool
26
    {
27 2
        return $message->hasData() && hash_equals($this->value, $message->getData());
28
    }
29
}
30