Passed
Push — master ( ab973d...b3288f )
by Smoren
02:37 queued 11s
created

Value::boolean()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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\BooleanRuleInterface;
8
use Smoren\Validator\Interfaces\MixedRuleInterface;
9
use Smoren\Validator\Interfaces\CompositeRuleInterface;
10
use Smoren\Validator\Interfaces\ContainerRuleInterface;
11
use Smoren\Validator\Interfaces\FloatRuleInterface;
12
use Smoren\Validator\Interfaces\NumericRuleInterface;
13
use Smoren\Validator\Interfaces\StringRuleInterface;
14
use Smoren\Validator\Rules\AllOfRule;
15
use Smoren\Validator\Rules\BooleanRule;
16
use Smoren\Validator\Rules\ContainerRule;
17
use Smoren\Validator\Rules\FloatRule;
18
use Smoren\Validator\Rules\IntegerRule;
19
use Smoren\Validator\Rules\MixedRule;
20
use Smoren\Validator\Rules\NumericRule;
21
use Smoren\Validator\Rules\StringRule;
22
use Smoren\Validator\Rules\AnyOfRule;
23
use Smoren\Validator\Structs\RuleName;
24
25
class Value
26
{
27
    /**
28
     * @param string $name
29
     *
30
     * @return NumericRule
31
     */
32 79
    public static function numeric(string $name = RuleName::NUMERIC): NumericRule
33
    {
34 79
        return new NumericRule($name);
35
    }
36
37
    /**
38
     * @param string $name
39
     *
40
     * @return NumericRuleInterface
41
     */
42 69
    public static function integer(string $name = RuleName::INTEGER): NumericRuleInterface
43
    {
44 69
        return new IntegerRule($name);
45
    }
46
47
    /**
48
     * @param string $name
49
     *
50
     * @return FloatRuleInterface
51
     */
52 48
    public static function float(string $name = RuleName::FLOAT): FloatRuleInterface
53
    {
54 48
        return new FloatRule($name);
55
    }
56
57
    /**
58
     * @param string $name
59
     *
60
     * @return BooleanRuleInterface
61
     */
62 22
    public static function boolean(string $name = RuleName::BOOLEAN): BooleanRuleInterface
63
    {
64 22
        return new BooleanRule($name);
65
    }
66
67
    /**
68
     * @param string $name
69
     *
70
     * @return StringRuleInterface
71
     */
72 24
    public static function string(string $name = RuleName::STRING): StringRuleInterface
73
    {
74 24
        return new StringRule($name);
75
    }
76
77
    /**
78
     * @param string $name
79
     *
80
     * @return ContainerRuleInterface
81
     */
82 56
    public static function container(string $name = RuleName::CONTAINER): ContainerRuleInterface
83
    {
84 56
        return new ContainerRule($name);
85
    }
86
87
    /**
88
     * @param string $name
89
     *
90
     * @return MixedRuleInterface
91
     */
92 19
    public static function mixed(string $name = RuleName::CONTAINER): MixedRuleInterface
93
    {
94 19
        return new MixedRule($name);
95
    }
96
97
    /**
98
     * @param array<MixedRuleInterface> $rules
99
     * @param string $name
100
     *
101
     * @return CompositeRuleInterface
102
     */
103 9
    public static function anyOf(array $rules, string $name = RuleName::OR): CompositeRuleInterface
104
    {
105 9
        return new AnyOfRule($rules, $name);
106
    }
107
108
    /**
109
     * @param array<MixedRuleInterface> $rules
110
     * @param string $name
111
     *
112
     * @return CompositeRuleInterface
113
     */
114 7
    public static function allOf(array $rules, string $name = RuleName::AND): CompositeRuleInterface
115
    {
116 7
        return new AllOfRule($rules, $name);
117
    }
118
}
119