Passed
Push — master ( c46ade...d14e7d )
by Mariano
02:11
created

FormFieldName   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 72.72%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A asString() 0 3 1
A __construct() 0 4 1
A equals() 0 3 1
A ensureIsNotEmpty() 0 4 2
1
<?php
2
3
namespace Mcustiel\Phiremock\Domain\Http;
4
5
class FormFieldName
6
{
7
    /** @var string * */
8
    private $fieldName;
9
10 2
    public function __construct(string $fieldName)
11
    {
12 2
        $this->ensureIsNotEmpty($fieldName);
13 2
        $this->fieldName = $fieldName;
14 2
    }
15
16 2
    public function asString(): string
17
    {
18 2
        return $this->fieldName;
19
    }
20
21
    public function equals(self $other): bool
22
    {
23
        return $other->asString() === $this->asString();
24
    }
25
26 2
    private function ensureIsNotEmpty(string $fieldName): void
27
    {
28 2
        if ($fieldName === '') {
29
            throw new \InvalidArgumentException('Field name can\t be empty');
30
        }
31 2
    }
32
}
33