Completed
Push — master ( 9af059...286024 )
by Luc
12s
created

NotEmptyString::toNative()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\Common\ValueObjects;
4
5
class NotEmptyString
6
{
7
    /**
8
     * @var string
9
     */
10
    private $value;
11
12
    /**
13
     * @param string $value
14
     */
15
    public function __construct(string $value)
16
    {
17
        $value = trim($value);
18
        if ($value === '') {
19
            throw new \InvalidArgumentException('The string value cannot be empty.');
20
        }
21
        $this->value = $value;
22
    }
23
24
    /**
25
     * @return string
26
     */
27
    public function toNative(): string
28
    {
29
        return $this->value;
30
    }
31
32
    /**
33
     * @param NotEmptyString $notEmptyString
34
     * @return bool
35
     */
36
    public function equals(NotEmptyString $notEmptyString): bool
37
    {
38
        return $this->toNative() === $notEmptyString->toNative();
39
    }
40
}
41