Completed
Push — master ( 608de6...159902 )
by Richard
05:43
created

Entities   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 28
wmc 3
lcom 0
cbo 2
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
id() 0 1 ?
A compile() 0 7 1
A eq_op() 0 8 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 licence along with the code.
9
 */
10
11
namespace Lechimp\Dicto\Variables;
12
13
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
14
15
abstract class Entities extends Variable {
16
    /**
17
     * Identifier for the type.
18
     *
19
     * @return  string
20
     */
21
    abstract public function id();
22
23
    /**
24
     * @inheritdocs
25
     */
26 44
    public function compile(ExpressionBuilder $builder, $table_name, $negate = false) {
27 44
        return $this->eq_op
28 44
            ( $builder
29 44
            , "$table_name.type"
30 44
            , $builder->literal($this->id())
31 44
            , $negate);
32
    }
33
34 49
    protected function eq_op(ExpressionBuilder $builder, $l, $r, $negate) {
35 49
        if (!$negate) {
36 45
            return $builder->eq($l, $r);
37
        }
38
        else {
39 18
            return $builder->neq($l, $r);
40
        }
41
    }
42
}
43
44