Artist   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 36 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 9
loc 25
rs 10
c 0
b 0
f 0
ccs 11
cts 12
cp 0.9167

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A assertValidName() 9 9 3
A getName() 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 HansOtt\Lastify\TrackInfo;
4
5
use InvalidArgumentException;
6
7
final class Artist
8
{
9
    private $name;
10
11 18
    public function __construct($name)
12
    {
13 18
        $this->assertValidName($name);
14 15
        $this->name = $name;
15 15
    }
16
17 18 View Code Duplication
    private function assertValidName($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...
18
    {
19 18
        if (!is_string($name)) {
20
            throw new InvalidArgumentException('The name should be a string, instead got:' . gettype($name));
21
        }
22 18
        if (empty($name)) {
23 3
            throw new InvalidArgumentException('The name cannot be empty');
24
        }
25 15
    }
26
27 3
    public function getName()
28
    {
29 3
        return $this->name;
30
    }
31
}
32