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

AsWellAs::__call()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 3.1825

Importance

Changes 4
Bugs 2 Features 0
Metric Value
dl 17
loc 17
ccs 8
cts 11
cp 0.7272
rs 9.4285
c 4
b 2
f 0
nc 3
cc 3
eloc 11
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 AsWellAs 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
    /**
19
     * Say to mean this class as well as the other class defined before.
20
     */
21 39
    public function __call($name, $arguments) {
22 39
        if (count($arguments) != 0) {
23
            # ToDo: This is used in Dicto::__callstatic as well.
24
            throw new \InvalidArgumentException(
25
                "No arguments are allowed for the reference to a variable.");
26
        }
27
28 39
        $left = $this->rt->get_current_var();
29 39
        $right = $this->rt->get_var($name);
30 39
        if (!($left instanceof Vars\Variable)) {
31
            throw new \RuntimeException("Could not get current var from runtime.");
32
        }
33 39
        $this->rt->current_var_is(
34 39
            new Vars\AsWellAs($this->rt->get_current_var_name(), $left, $right));
35
36 39
        return new ExistingVar($this->rt);
37
    }
38
}
39