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

FormFieldName::ensureIsNotEmpty()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 2
cts 3
cp 0.6667
crap 2.1481
rs 10
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