Passed
Push — master ( 3740bc...e69f3f )
by Richard
05:30
created

_Combined::compiled_predicates()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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\Predicate;
12
13
use Lechimp\Dicto\Graph\Predicate;
14
15
/**
16
 * A predicate that is some combination of other predicates.
17
 */
18
abstract class _Combined extends Predicate {
19
    /**
20
     * @var Predicate[]
21
     */
22
    protected $predicates;
23
24 44
    public function __construct(array $predicates) {
25
        $this->predicates = array_map(function(Predicate $p) {
26 44
            return $p;
27 44
        }, $predicates);
28 44
    }
29
30
    /**
31
     * @return  \Closure[]
32
     */
33 40
    protected function compiled_predicates() {
34
        return array_map(function($p) {
35 40
            return $p->compile();
36 40
        }, $this->predicates);
37
    }
38
39
    /**
40
     * @param   string[]
41
     * @return  string[][]
42
     */
43
    protected function for_types_of_predicates(array $existing_types) {
44 36
        return array_map(function($p) use ($existing_types) {
45 36
            return $p->for_types($existing_types);
46 36
        }, $this->predicates);
47
    }
48
}
49