Completed
Push — master ( 05840b...9b2a73 )
by Richard
05:47
created

_True::_compile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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\Predicate;
12
13
use Lechimp\Dicto\Graph\Predicate;
14
use Lechimp\Dicto\Graph\Entity;
15
16
/**
17
 * A predicate that is always true.
18
 */
19
class _True extends Predicate {
20
    /**
21
     * @inheritdocs
22
     */
23
    public function _compile() {
24
        return function() { return true; };
25
    }
26
27
    /**
28
     * @inheritdocs
29
     */
30 17
    public function compile_to_source(array &$custom_closures) {
31 17
        return "    \$value = true;\n";
32
    }
33
34
    /**
35
     * @inheritdocs
36
     */
37 10
    public function for_types(array $existing_types) {
38 10
        return $existing_types;
39
    }
40
}
41