Completed
Push — master ( 389cae...29b40e )
by Richard
06:27
created

Relation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 85.71%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 3
dl 0
loc 24
ccs 12
cts 14
cp 0.8571
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 12 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\Definition\Fluid;
12
use \Lechimp\Dicto\Definition as Def;
13
use \Lechimp\Dicto\Rules as Rules;
14
15
class Relation extends BaseWithNameAndMode {
16
    /**
17
     * @var R\Relation
18
     */
19
    protected $relation;
20
21 150
    public function __construct(Def\RuleDefinitionRT $rt, $name, $mode, Rules\Relation $relation) {
22 150
        parent::__construct($rt, $name, $mode);
23 150
        $this->relation = $relation;
0 ignored issues
show
Documentation Bug introduced by
It seems like $relation of type object<Lechimp\Dicto\Rules\Relation> is incompatible with the declared type object<Lechimp\Dicto\Definition\Fluid\R\Relation> of property $relation.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24 150
    } 
25
26 150
    public function __call($name, $arguments) {
27 150
        if (count($arguments) != 0) {
28
            throw new \InvalidArgumentException(
29
                "No arguments are allowed for a reference to a variable.");
30
        }
31 150
        $this->rt->throw_on_missing_var($name);
32
33 150
        $left = $this->rt->get_var($this->name);
34 150
        $right = $this->rt->get_var($name);
35 150
        $this->rt->add_rule(
36 150
            new Rules\Rule($this->mode, $left, $this->relation, array($right)));
37 150
    }
38
}
39