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

Text::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

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