ValueMatcher::isLessThan()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PHPKitchen\CodeSpecsCore\Expectation\Matcher;
4
5
use PHPKitchen\CodeSpecsCore\Expectation\Matcher\Base\Matcher;
6
7
/**
8
 * ValueMatcher is designed to check given value matches expectation.
9
 *
10
 * @package PHPKitchen\CodeSpecsCore\Expectation
11
 * @author Dmitry Kolodko <[email protected]>
12
 */
13
class ValueMatcher extends Matcher {
14
    /**
15
     * @return $this
16
     */
17
    public function isInternalType($type): self {
18
        $this->startStep('is internal type "' . $type . '"')
19
            ->assertInternalType($type);
20
        return $this;
21
    }
22
23
    /**
24
     * @return $this
25
     */
26
    public function isNotInternalType($type): self {
27
        $this->startStep('is not internal type "' . $type . '"')
28
            ->assertNotInternalType($type);
29
        return $this;
30
    }
31
32
    /**
33
     * @return $this
34
     */
35
    public function isEqualTo($expected, $expectedValueName = '') {
36
        $stepName = $expectedValueName ? "is equal to {$expectedValueName}" : "is equal to expected";
37
38
        $this->startStep($stepName)
39
            ->assertEquals($expected);
40
        return $this;
41
    }
42
43
    /**
44
     * @return $this
45
     */
46
    public function isNotEqualTo($expected, $expectedValueName = '') {
47
        $stepName = $expectedValueName ? "is not equal to {$expectedValueName}" : "is not equal to expected";
48
        $this->startStep($stepName)
49
            ->assertNotEquals($expected);
50
        return $this;
51
    }
52
53
    /**
54
     * @return $this
55
     */
56
    public function isGreaterThan($expected): self {
57
        $this->startStep('is greater than "' . $expected . '"')
58
            ->assertGreaterThan($expected);
59
        return $this;
60
    }
61
62
    /**
63
     * @return $this
64
     */
65
    public function isLessThan($expected): self {
66
        $this->startStep('is less than "' . $expected . '"')
67
            ->assertLessThan($expected);
68
        return $this;
69
    }
70
71
    /**
72
     * @return $this
73
     */
74
    public function isGreaterOrEqualTo($expected): self {
75
        $this->startStep('is greater or equal to "' . $expected . '"')
76
            ->assertGreaterThanOrEqual($expected);
77
        return $this;
78
    }
79
80
    /**
81
     * @return $this
82
     */
83
    public function isLessOrEqualTo($expected): self {
84
        $this->startStep('is less or equal to "' . $expected . '"')
85
            ->assertLessThanOrEqual($expected);
86
        return $this;
87
    }
88
89
    /**
90
     * @return $this
91
     */
92
    public function isNull(): self {
93
        $this->startStep('is null')
94
            ->assertNull();
95
        return $this;
96
    }
97
98
    /**
99
     * @return $this
100
     */
101
    public function isNotNull(): self {
102
        $this->startStep('is not null')
103
            ->assertNotNull();
104
        return $this;
105
    }
106
107
    /**
108
     * @return $this
109
     */
110
    public function isEmpty(): self {
111
        $this->startStep('is empty')
112
            ->assertEmpty();
113
        return $this;
114
    }
115
116
    /**
117
     * @return $this
118
     */
119
    public function isNotEmpty(): self {
120
        $this->startStep('is not empty')
121
            ->assertNotEmpty();
122
        return $this;
123
    }
124
125
    /**
126
     * @return $this
127
     */
128
    public function isTheSameAs($expected, $expectedValueName = '') {
129
        $stepName = $expectedValueName ? "is the same as {$expectedValueName}" : "is the same as expected";
130
        $this->startStep($stepName)
131
            ->assertSame($expected);
132
        return $this;
133
    }
134
135
    /**
136
     * @return $this
137
     */
138
    public function isNotTheSameAs($expected, $expectedValueName = '') {
139
        $stepName = $expectedValueName ? "is not the same as {$expectedValueName}" : "is not the same as expected";
140
141
        $this->startStep($stepName)
142
            ->assertNotSame($expected);
143
        return $this;
144
    }
145
}