Completed
Push — master ( 1e9ef5...3740bc )
by Richard
05:53 queued 29s
created

PropertyPredicateFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 * 
5
 * Copyright (c) 2016 Richard Klees <[email protected]>
6
 *
7
 * This software is licensed under The MIT License. You should have received 
8
 * a copy of the license along with the code.
9
 */
10
11
namespace Lechimp\Dicto\Graph;
12
13
/**
14
 * Create some predicate over a property.
15
 */
16
class PropertyPredicateFactory {
17
    /**
18
     * @var string
19
     */
20
    protected $name;
21
22 30
    public function __construct($name) {
23 30
        assert('is_string($name)');
24 30
        $this->name = $name;
25 30
    }
26
27
    /**
28
     * Is true when the property matches the given regex.
29
     *
30
     * @param   string  $regex
31
     * @return  Predicate
32
     */
33 30
    public function _matches($regex) {
34 30
        return new Predicate\_PropertyMatches($this->name, $regex);
35
    }
36
}
37