Passed
Branch master (aecce8)
by Brice
05:03
created

Profile   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A __toString() 0 3 1
A getName() 0 3 1
1
<?php
2
3
namespace JobQueue\Domain\Task;
4
5
final class Profile
6
{
7
    /**
8
     *
9
     * @var string
10
     */
11
    private $name;
12
13
    /**
14
     *
15
     * @param string $name
16
     */
17 30
    public function __construct(string $name)
18
    {
19 30
        if (!preg_match('/^[_a-z0-9-]+$/', $name)) {
20 1
            throw new \RuntimeException('Profile name only allows lowercase alphanumerical, dash and underscore characters');
21
        }
22
23 29
        $this->name = $name;
24 29
    }
25
26
    /**
27
     *
28
     * @return string
29
     */
30
    public function getName(): string
31
    {
32
        return $this->name;
33
    }
34
35
    /**
36
     *
37
     * @return string
38
     */
39 20
    public function __toString()
40
    {
41 20
        return $this->name;
42
    }
43
}
44