Passed
Push — 1.0.0 ( 681a4e...b8a5a2 )
by Alex
01:34
created

Name   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A checkValueIsAValidName() 0 4 2
A fromValue() 0 4 1
A value() 0 3 1
1
<?php
2
3
namespace StraTDeS\VO;
4
5
class Name
6
{
7
    private string $value;
8
9 1
    private function __construct(string $value)
10
    {
11 1
        $this->value = $value;
12 1
    }
13
14 2
    public static function fromValue(string $value): Name
15
    {
16 2
        self::checkValueIsAValidName($value);
17 1
        return new Name($value);
18
    }
19
20 2
    private static function checkValueIsAValidName(string $value): void
21
    {
22 2
        if (strlen($value) === 0) {
23 1
            throw new \InvalidArgumentException("Name value must have at least one character");
24
        }
25 1
    }
26
27 1
    public function value(): string
28
    {
29 1
        return $this->value;
30
    }
31
}
32