Code Duplication    Length = 17-22 lines in 2 locations

src/Definition/Fluid/AsWellAs.php 1 location

@@ 17-38 (lines=22) @@
14
/**
15
 * Provides fluid interface to as_well_as().
16
 */
17
class AsWellAs extends Base {
18
    /**
19
     * Say to mean this class as well as the other class defined before.
20
     */
21
    public function __call($name, $arguments) {
22
        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
        $left = $this->rt->get_current_var();
29
        $right = $this->rt->get_var($name);
30
        if (!($left instanceof Vars\Variable)) {
31
            throw new \RuntimeException("Could not get current var from runtime.");
32
        }
33
        $this->rt->current_var_is(
34
            new Vars\AsWellAs($this->rt->get_current_var_name(), $left, $right));
35
36
        return new ExistingVar($this->rt);
37
    }
38
}
39

src/Definition/Fluid/ButNot.php 1 location

@@ 17-33 (lines=17) @@
14
/**
15
 * Provides fluid interface to as_well_as().
16
 */
17
class ButNot extends Base {
18
    public function __call($name, $arguments) {
19
        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
        $left = $this->rt->get_current_var();
26
        $right = $this->rt->get_var($name);
27
        if (!($left instanceof Vars\Variable)) {
28
            throw new \RuntimeException("Could not get current var from runtime.");
29
        }
30
        $this->rt->current_var_is(
31
            new Vars\ButNot($this->rt->get_current_var_name(), $left, $right));
32
    }
33
}
34