Completed
Push — master ( e2dc10...6f7e0c )
by Richard
06:21
created

Invoke   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 57.14%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 5
c 4
b 1
f 1
lcom 1
cbo 1
dl 42
loc 42
ccs 8
cts 14
cp 0.5714
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A invoke() 3 3 1
A invokes() 3 3 1
A explain() 5 5 1
A variables() 3 3 1

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\Rules;
12
use Lechimp\Dicto\Definition\Variables as Vars;
13
14 View Code Duplication
class Invoke extends Rule {
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...
15
    /**
16
     * @var Vars\Variable
17
     */
18
    private $invokes;
19
20
    /**
21
     * @param string $mode
22
     */
23 54
    public function __construct($mode, Vars\Variable $left, Vars\Variable $invokes) {
24 54
        parent::__construct($mode, $left);
25 54
        $this->invokes = $invokes;
26 54
    }
27
28
    // TODO: This seems odd. Its part of a fluid interface, right?
29
    public function invoke(Functions $fun) {
30
        return InvokeRule($this, $fun);
31
    }
32
33
    /**
34
     * @return Vars\Variable
35
     */
36 12
    public function invokes() {
37 12
        return $this->invokes;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function explain($text) {
44
        $r = new InvokeRule($this->mode(), $this->subject(), $this->invokes);
45
        $r->setExplanation($text);
46
        return $r;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52 1
    public function variables() {
53 1
        return array($this->subject(), $this->invokes);
54
    }
55
}
56
57