Passed
Push — master ( 4fbf5c...1ab1c0 )
by Smoren
02:13
created

Value::string()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Validator\Factories;
6
7
use Smoren\Validator\Interfaces\RuleInterface;
8
use Smoren\Validator\Interfaces\CompositeRuleInterface;
9
use Smoren\Validator\Interfaces\ContainerRuleInterface;
10
use Smoren\Validator\Interfaces\FloatRuleInterface;
11
use Smoren\Validator\Interfaces\IntegerRuleInterface;
12
use Smoren\Validator\Interfaces\StringRuleInterface;
13
use Smoren\Validator\Rules\AndRule;
14
use Smoren\Validator\Rules\ContainerRule;
15
use Smoren\Validator\Rules\FloatRule;
16
use Smoren\Validator\Rules\IntegerRule;
17
use Smoren\Validator\Rules\NumericRule;
18
use Smoren\Validator\Rules\StringRule;
19
use Smoren\Validator\Rules\OrRule;
20
use Smoren\Validator\Structs\RuleName;
21
22
class Value
23
{
24
    /**
25
     * @param string $name
26
     *
27
     * @return NumericRule
28
     */
29 33
    public static function numeric(string $name = RuleName::NUMERIC): NumericRule
30
    {
31 33
        return new NumericRule($name);
32
    }
33
34
    /**
35
     * @param string $name
36
     *
37
     * @return IntegerRuleInterface
38
     */
39 57
    public static function integer(string $name = RuleName::INTEGER): IntegerRuleInterface
40
    {
41 57
        return new IntegerRule($name);
42
    }
43
44
    /**
45
     * @param string $name
46
     *
47
     * @return FloatRuleInterface
48
     */
49 42
    public static function float(string $name = RuleName::FLOAT): FloatRuleInterface
50
    {
51 42
        return new FloatRule($name);
52
    }
53
54
    /**
55
     * @param string $name
56
     *
57
     * @return StringRuleInterface
58
     */
59
    public static function string(string $name = RuleName::STRING): StringRuleInterface
60
    {
61
        return new StringRule($name);
62
    }
63
64
    /**
65
     * @param string $name
66
     *
67
     * @return ContainerRuleInterface
68
     */
69 19
    public static function container(string $name = RuleName::CONTAINER): ContainerRuleInterface
70
    {
71 19
        return new ContainerRule($name);
72
    }
73
74
    /**
75
     * @param array<RuleInterface> $rules
76
     * @param string $name
77
     *
78
     * @return CompositeRuleInterface
79
     */
80 9
    public static function or(array $rules, string $name = RuleName::OR): CompositeRuleInterface
81
    {
82 9
        return new OrRule($rules, $name);
83
    }
84
85
    /**
86
     * @param array<RuleInterface> $rules
87
     * @param string $name
88
     *
89
     * @return CompositeRuleInterface
90
     */
91
    public static function and(array $rules, string $name = RuleName::AND): CompositeRuleInterface
92
    {
93
        return new AndRule($rules, $name);
94
    }
95
}
96