Completed
Push — master ( 21e2dd...2fbabb )
by Dominik
02:22 queued 20s
created

AllowOriginRegex   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A match() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Cors\Negotiation\Origin;
6
7
final class AllowOriginRegex implements AllowOriginInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $pattern;
13
14
    /**
15
     * @param string $pattern
16
     */
17 2
    public function __construct(string $pattern)
18
    {
19 2
        $this->pattern = $pattern;
20 2
    }
21
22
    /**
23
     * @param string $origin
24
     *
25
     * @return bool
26
     */
27 2
    public function match(string $origin): bool
28
    {
29 2
        return 1 === preg_match('!'.$this->pattern.'!', $origin);
30
    }
31
}
32