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

AsWellAs   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 72.72%

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 22
loc 22
ccs 8
cts 11
cp 0.7272
rs 10
c 4
b 2
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 17 17 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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