Completed
Push — master ( 5b9a3a...d89495 )
by Hans
03:39
created

Artist::assertValidName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
ccs 5
cts 6
cp 0.8333
rs 9.6666
cc 3
eloc 5
nc 3
nop 1
crap 3.0416
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