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

_Combined   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 70%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A for_types_of_predicates() 0 5 1
A compiled_predicates() 0 5 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