Completed
Push — master ( 7db57b...89e945 )
by Nikolas
04:32
created

GenericMethodAction   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 28 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 7
c 5
b 0
f 1
lcom 1
cbo 2
dl 14
loc 50
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 14 1
A generic() 0 3 1
A execute() 0 3 1
A caption() 0 3 1
A description() 0 3 1
A fill() 0 3 1
A parameters() 0 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
namespace rtens\domin\reflection;
3
4
use rtens\domin\reflection\types\TypeFactory;
5
6
class GenericMethodAction extends MethodAction {
7
8
    /** @var GenericAction */
9
    private $generic;
10
11
    /**
12
     * @param object $object
13
     * @param string $method
14
     * @param TypeFactory $types
15
     * @param CommentParser $parser
16
     */
17 View Code Duplication
    public function __construct($object, $method, TypeFactory $types, CommentParser $parser) {
0 ignored issues
show
Duplication introduced by
This method 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
        parent::__construct($object, $method, $types, $parser);
19
        $this->generic = new GenericAction($this);
20
        $this->generic
21
            ->setCaption(parent::caption())
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (caption() instead of __construct()). Are you sure this is correct? If so, you might want to change this to $this->caption().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
22
            ->setDescription(parent::description())
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (description() instead of __construct()). Are you sure this is correct? If so, you might want to change this to $this->description().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
23
            ->setParameters(parent::parameters())
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (parameters() instead of __construct()). Are you sure this is correct? If so, you might want to change this to $this->parameters().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
24
            ->setExecute(function ($parameters) {
25
                return parent::execute($parameters);
26
            })
27
            ->setFill(function ($parameters) {
28
                return $parameters;
29
            });
30
    }
31
32
    public function generic() {
33
        return $this->generic;
34
    }
35
36
    public function execute(array $parameters) {
37
        return $this->generic->execute($parameters);
38
    }
39
40
    public function caption() {
41
        return $this->generic->caption();
42
    }
43
44
    public function description() {
45
        return $this->generic->description();
46
    }
47
48
    public function fill(array $parameters) {
49
        return $this->generic->fill(parent::fill($parameters));
50
    }
51
52
    public function parameters() {
53
        return $this->generic->parameters();
54
    }
55
}