Completed
Push — master ( 70a760...de59c0 )
by Vladimir
04:07 queued 01:42
created

Regex   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matches() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Conversation\Activators;
6
7
use FondBot\Events\MessageReceived;
8
use Spatie\Regex\Regex as SpatieRegex;
9
use FondBot\Contracts\Conversation\Activator;
10
11
class Regex implements Activator
12
{
13
    protected $pattern;
14
15 3
    public function __construct(string $pattern)
16
    {
17 3
        $this->pattern = $pattern;
18 3
    }
19
20
    /**
21
     * Result of matching activator.
22
     *
23
     * @param MessageReceived $message
24
     *
25
     * @return bool
26
     */
27 2
    public function matches(MessageReceived $message): bool
28
    {
29 2
        $text = $message->getText();
30
31 2
        return SpatieRegex::match($this->pattern, $text)->hasMatch();
32
    }
33
}
34