Method   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 30 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 12
loc 40
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 12 12 3
A __toString() 0 4 1
A isEqualTo() 0 4 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
namespace Isolate\LazyObjects\Proxy;
4
5
use Isolate\LazyObjects\Exception\InvalidArgumentException;
6
7
/**
8
 * @api
9
 */
10
class Method
11
{
12
    /**
13
     * @var string
14
     */
15
    private $name;
16
17
    /**
18
     * @param string $name
19
     * @throws InvalidArgumentException
20
     */
21 View Code Duplication
    public function __construct($name)
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...
22
    {
23
        if (!is_string($name)) {
24
            throw new InvalidArgumentException("Method name must be a valid string.");
25
        }
26
27
        if (empty($name)) {
28
            throw new InvalidArgumentException("Method name can not be empty.");
29
        }
30
31
        $this->name = $name;
32
    }
33
34
    public function __toString()
35
    {
36
        return $this->name;
37
    }
38
39
    /**
40
     * @param $method
41
     * @return bool
42
     * 
43
     * @api
44
     */
45
    public function isEqualTo($method)
46
    {
47
        return strtolower($this->name) === strtolower($method);
48
    }
49
}
50