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

_Combined::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
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\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 52
    public function __construct(array $predicates) {
25
        $this->predicates = array_map(function(Predicate $p) {
26 52
            return $p;
27 52
        }, $predicates);
28 52
    }
29
30
    /**
31
     * @return  \Closure[]
32
     */
33
    protected function compiled_predicates() {
34
        return array_map(function($p) {
35
            return $p->compile();
36
        }, $this->predicates);
37
    }
38
39
    /**
40
     * @param   string[]
41
     * @return  string[][]
42
     */
43
    protected function for_types_of_predicates(array $existing_types) {
44 41
        return array_map(function($p) use ($existing_types) {
45 41
            return $p->for_types($existing_types);
46 41
        }, $this->predicates);
47
    }
48
}
49