Passed
Push — master ( 637623...02963c )
by Dedipyaman
02:11
created

StringRequired   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A getValue() 0 3 1
A __construct() 0 6 2
1
<?php
2
/*
3
 * This file is part of Skletter <https://github.com/2DSharp/Skletter>.
4
 *
5
 * (c) Dedipyaman Das <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Phypes\Type;
12
13
14
use Phypes\Exception\EmptyRequiredValue;
15
16
class StringRequired implements Type
17
{
18
    /**
19
     * @var string $value
20
     */
21
    private $value;
22
23
    /**
24
     * Required constructor.
25
     * @param string $text
26
     * @throws EmptyRequiredValue
27
     */
28
    public function __construct(string $text)
29
    {
30
        if (empty($text))
31
            throw new EmptyRequiredValue();
32
33
        $this->value = $text;
34
    }
35
36
    public function __toString(): string
37
    {
38
        return $this->value;
39
    }
40
41
    public function getValue()
42
    {
43
        return $this->value;
44
    }
45
}