Completed
Push — master ( 8a8a78...0e8a0f )
by Kevin
19s queued 13s
created

PatternMatches::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Wallabag\CoreBundle\Operator\PHP;
4
5
/**
6
 * Provides a "~" operator used for ignore origin rules.
7
 *
8
 * It asserts that a subject matches a given regexp pattern, in a
9
 * case-insensitive way.
10
 *
11
 * This operator will be used to compile ignore origin rules in PHP, usable
12
 * directly on Entry objects for instance.
13
 * It's registered in RulerZ using a service (wallabag.operator.array.pattern_matches);
14
 */
15
class PatternMatches
16
{
17
    public function __invoke($subject, $pattern)
18
    {
19
        $count = preg_match("`$pattern`i", $subject);
20
21
        return \is_int($count) && $count > 0;
22
    }
23
}
24