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

PropertyPredicateFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A _matches() 0 3 1
A _equals() 0 3 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