Completed
Pull Request — master (#4)
by Woody
02:33
created

Text::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Equip\ValueObject;
4
5
use InvalidArgumentException;
6
7
use function Assert\that;
8
9
class Text
10
{
11
    /**
12
     * @var string|null
13
     */
14
    private $value;
15
16 12
    public function __construct($value, $regex = null)
17
    {
18 12
        $assert = that($value)->nullOr()->string();
19
20 7
        if ($regex) {
21 4
            $assert->regex($regex);
22 2
        }
23
24 5
        $this->value = $value;
25 5
    }
26
27 5
    public function value()
28
    {
29 5
        return $this->value;
30
    }
31
}
32