Completed
Push — master ( a22976...bdfc9e )
by Vladimir
03:53
created

Payload   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A make() 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\Events\MessageReceived;
8
use FondBot\Contracts\Conversation\Activator;
9
10
class Payload implements Activator
11
{
12
    protected $value;
13
14 2
    protected function __construct(string $value)
15
    {
16 2
        $this->value = $value;
17 2
    }
18
19 2
    public static function make(string $value)
20
    {
21 2
        return new static($value);
22
    }
23
24
    /**
25
     * Result of matching activator.
26
     *
27
     * @param MessageReceived $message
28
     *
29
     * @return bool
30
     */
31 2
    public function matches(MessageReceived $message): bool
32
    {
33 2
        return $message->getData() ? hash_equals($this->value, $message->getData()) : false;
34
    }
35
}
36