Completed
Push — master ( 14784f...87aa66 )
by Richard
05:56
created

ButNot::__call()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 3.1825

Importance

Changes 4
Bugs 1 Features 0
Metric Value
dl 15
loc 15
ccs 8
cts 11
cp 0.7272
rs 9.4285
c 4
b 1
f 0
nc 3
cc 3
eloc 10
nop 2
crap 3.1825
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\Variables as Vars;
13
14
/**
15
 * Provides fluid interface to as_well_as().
16
 */
17 View Code Duplication
class ButNot extends Base {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18 38
    public function __call($name, $arguments) {
19 38
        if (count($arguments) != 0) {
20
            # ToDo: This is used in Dicto::__callstatic as well.
21
            throw new \InvalidArgumentException(
22
                "No arguments are allowed for the reference to a variable.");
23
        }
24
25 38
        $left = $this->rt->get_current_var();
26 38
        $right = $this->rt->get_var($name);
27 38
        if (!($left instanceof Vars\Variable)) {
28
            throw new \RuntimeException("Could not get current var from runtime.");
29
        }
30 38
        $this->rt->current_var_is(
31 38
            new Vars\ButNot($this->rt->get_current_var_name(), $left, $right));
32 38
    }
33
}
34