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

PredicateFactory   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 8
dl 0
loc 79
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A _true() 0 3 1
A _false() 0 3 1
A _and() 0 3 1
A _or() 0 3 1
A _not() 0 3 1
A _type_is() 0 3 1
A _property() 0 3 1
A _custom() 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
/**
14
 * Factory for Predicates on Nodes.
15
 */
16
class PredicateFactory {
17
    /**
18
     * A predicate that is always true.
19
     *
20
     * @return  Predicate
21
     */
22 19
    public function _true() {
23 19
        return new Predicate\_True();
24
    }
25
26
    /**
27
     * A predicate that is always false.
28
     *
29
     * @return  Predicate
30
     */
31 12
    public function _false() {
32 12
        return new Predicate\_False();
33
    }
34
35
    /**
36
     * Connect some predicates with AND.
37
     *
38
     * @param   Predicate[]     $predicates
39
     * @return  Predicate
40
     */
41 32
    public function _and(array $predicates) {
42 32
        return new Predicate\_And($predicates);
43
    }
44
45
    /**
46
     * Connect some predicates with OR.
47
     *
48
     * @param   Predicate[]     $predicates
49
     * @return  Predicate
50
     */
51 39
    public function _or(array $predicates) {
52 39
        return new Predicate\_Or($predicates);
53
    }
54
55
    /**
56
     * A negated predicate.
57
     *
58
     * @param   Predicate       $predicate
59
     * @return  Predicate
60
     */
61 10
    public function _not(Predicate $predicate) {
62 10
        return new Predicate\_Not($predicate);
63
    }
64
65
    /**
66
     * Is true when the node has the given type.
67
     *
68
     * @param   string      $type
69
     * @return  Predicate
70
     */
71 41
    public function _type_is($type) {
72 41
        return new Predicate\_TypeIs($type);
73
    }
74
75
    /**
76
     * A predicate about some property.
77
     *
78
     * @param   string      $name
79
     * @return  PropertyPredicate
80
     */
81 30
    public function _property($name) {
82 30
        return new PropertyPredicateFactory($name);
83
    }
84
85
    /**
86
     * A custom predicate.
87
     *
88
     * @param   \Closure    $predicate  Entity -> bool
0 ignored issues
show
Bug introduced by
There is no parameter named $predicate. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
89
     * @return  Predicate
90
     */
91 39
    public function _custom(\Closure $closure) {
92 39
        return new Predicate\_Custom($closure);
93
    }
94
}
95