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

FormFieldName::asString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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