IsMatchingRegex   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 19
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 9 2
1
<?php
2
/**
3
 * Created by gerk on 30.11.17 05:44
4
 */
5
6
namespace PeekAndPoke\Component\Psi\Psi\Str;
7
8
use PeekAndPoke\Component\Psi\Functions\ParameterizedUnaryFunction;
9
use PeekAndPoke\Types\ValueHolder;
10
11
/**
12
 * @author Karsten J. Gerber <[email protected]>
13
 */
14
class IsMatchingRegex extends ParameterizedUnaryFunction
15
{
16
    /**
17
     * @param mixed|ValueHolder $regex
18
     */
19 44
    public function __construct($regex)
20
    {
21 44
        parent::__construct($regex);
22 44
    }
23
24 44
    public function __invoke($input)
25
    {
26 44
        if (! is_scalar($input)) {
27 4
            return false;
28
        }
29
30 40
        $regex = $this->getValue();
31
32 40
        return preg_match($regex, $input) === 1;
33
    }
34
}
35