Completed
Push — master ( 470c23...605cf4 )
by Richard
08:11
created

PropertyPredicateFactory::_equals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
use Lechimp\Dicto\Regexp;
14
15
/**
16
 * Create some predicate over a property.
17
 */
18
class PropertyPredicateFactory {
19
    /**
20
     * @var string
21
     */
22
    protected $name;
23
24 35
    public function __construct($name) {
25 35
        assert('is_string($name)');
26 35
        $this->name = $name;
27 35
    }
28
29
    /**
30
     * Is true when the property matches the given regex.
31
     *
32
     * @param   Regexp  $regex
33
     * @return  Predicate
34
     */
35 29
    public function _matches(Regexp $regex) {
36 29
        return new Predicate\_PropertyMatches($this->name, $regex);
37
    }
38
39
    /**
40
     * Is true when the property equals the given value.
41
     *
42
     * @param   string      $value 
43
     * @return  Predicate
44
     */
45 6
    public function _equals($value) {
46 6
        return new Predicate\_PropertyEquals($this->name, $value);
47
    }
48
}
49