Passed
Push — feature/VSVGVQ-7 ( ab245d...5131d3 )
by steven
05:54 queued 36s
created

NotEmptyString   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A toNative() 0 3 1
A equals() 0 3 1
1
<?php
2
3
namespace VSV\GVQ_API\Question;
4
5
class NotEmptyString
6
{
7
    /**
8
     * @var string
9
     */
10
    private $text;
11
12
    /**
13
     * @param string $text
14
     */
15
    public function __construct(string $text)
16
    {
17
        $text = trim($text);
18
        if ($text === '') {
19
            throw new \InvalidArgumentException('Text argument cannot be empty.');
20
        }
21
        $this->text = $text;
22
    }
23
24
    /**
25
     * @return string
26
     */
27
    public function toNative(): string
28
    {
29
        return $this->text;
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