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

AllowOriginRegex::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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