StringMatcher::isNotEqualToFile()   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
/**
6
 * StringMatcher is designed to check given string matches expectation.
7
 *
8
 * @package PHPKitchen\CodeSpecsCore\Expectation
9
 * @author Dmitry Kolodko <[email protected]>
10
 */
11
class StringMatcher extends ValueMatcher {
12
    /**
13
     * @return $this
14
     */
15
    public function isJson(): self {
16
        $this->startStep('is JSON')
17
            ->assertJson();
18
        return $this;
19
    }
20
21
    /**
22
     * @return $this
23
     */
24
    public function isEqualToJsonFile($file): self {
25
        $this->startStep('is equal to JSON file "' . $file . '"')
26
            ->assertJsonStringEqualsJsonFile($file);
27
        return $this;
28
    }
29
30
    /**
31
     * @return $this
32
     */
33
    public function isNotEqualToJsonFile($file): self {
34
        $this->startStep('is not equal to JSON file "' . $file . '"')
35
            ->assertJsonStringNotEqualsJsonFile($file);
36
        return $this;
37
    }
38
39
    /**
40
     * @return $this
41
     */
42
    public function isEqualToJsonString($string): self {
43
        $this->startStep('is equal to JSON string "' . $string . '"')
44
            ->assertJsonStringEqualsJsonString($string);
45
        return $this;
46
    }
47
48
    /**
49
     * @return $this
50
     */
51
    public function isNotEqualToJsonString($string): self {
52
        $this->startStep('is not equal to JSON string "' . $string . '"')
53
            ->assertJsonStringNotEqualsJsonString($string);
54
        return $this;
55
    }
56
57
    /**
58
     * @return $this
59
     */
60
    public function isEqualToFile($file): self {
61
        $this->startStep('is equal to file "' . $file . '"')
62
            ->assertStringEqualsFile($file);
63
        return $this;
64
    }
65
66
    /**
67
     * @return $this
68
     */
69
    public function isNotEqualToFile($file): self {
70
        $this->startStep('is not equal to file "' . $file . '"')
71
            ->assertStringNotEqualsFile($file);
72
        return $this;
73
    }
74
75
    /**
76
     * @return $this
77
     */
78
    public function isEqualToXmlFile($file): self {
79
        $this->startStep('is equal to XML file "' . $file . '"')
80
            ->assertXmlStringEqualsXmlFile($file);
81
        return $this;
82
    }
83
84
    /**
85
     * @return $this
86
     */
87
    public function isNotEqualToXmlFile($file): self {
88
        $this->startStep('is not equal to XML file "' . $file . '"')
89
            ->assertXmlStringNotEqualsXmlFile($file);
90
        return $this;
91
    }
92
93
    /**
94
     * @return $this
95
     */
96
    public function isEqualToXmlString($xmlString): self {
97
        $this->startStep('is equal to XML string "' . $xmlString . '"')
98
            ->assertXmlStringEqualsXmlString($xmlString);
99
        return $this;
100
    }
101
102
    /**
103
     * @return $this
104
     */
105
    public function isNotEqualToXmlString($xmlString): self {
106
        $this->startStep('is not equal to XML string "' . $xmlString . '"')
107
            ->assertXmlStringNotEqualsXmlString($xmlString);
108
        return $this;
109
    }
110
111
    /**
112
     * @return $this
113
     */
114
    public function startsWith($prefix): self {
115
        $this->startStep('starts with "' . $prefix . '"')
116
            ->assertStringStartsWith($prefix);
117
        return $this;
118
    }
119
120
    /**
121
     * @return $this
122
     */
123
    public function doesNotStartWith($prefix): self {
124
        $this->startStep('does not start with "' . $prefix . '"')
125
            ->assertStringStartsNotWith($prefix);
126
        return $this;
127
    }
128
129
    /**
130
     * @return $this
131
     */
132
    public function endsWith($suffix): self {
133
        $this->startStep('ends with "' . $suffix . '"')
134
            ->assertStringEndsWith($suffix);
135
        return $this;
136
    }
137
138
    /**
139
     * @return $this
140
     */
141
    public function doesNotEndWith($suffix): self {
142
        $this->startStep('does not end with "' . $suffix . '"')
143
            ->assertStringEndsNotWith($suffix);
144
        return $this;
145
    }
146
147
    /**
148
     * @return $this
149
     */
150
    public function matchesRegExp($expression): self {
151
        $this->startStep('matches regular expression "' . $expression . '"')
152
            ->assertRegExp($expression);
153
        return $this;
154
    }
155
156
    /**
157
     * @return $this
158
     */
159
    public function matchesFormat($format): self {
160
        $this->startStep('matches format "' . $format . '"')
161
            ->assertStringMatchesFormat($format);
162
        return $this;
163
    }
164
165
    /**
166
     * @return $this
167
     */
168
    public function doesNotMatchFormat($format): self {
169
        $this->startStep('does not match format "' . $format . '"')
170
            ->assertStringNotMatchesFormat($format);
171
        return $this;
172
    }
173
174
    /**
175
     * @return $this
176
     */
177
    public function matchesFormatFromFile($formatFile): self {
178
        $this->startStep('matches format from file "' . $formatFile . '"')
179
            ->assertStringMatchesFormatFile($formatFile);
180
        return $this;
181
    }
182
183
    /**
184
     * @return $this
185
     */
186
    public function doesNotMatchFormatFromFile($formatFile): self {
187
        $this->startStep('does not match format from file "' . $formatFile . '"')
188
            ->assertStringNotMatchesFormatFile($formatFile);
189
        return $this;
190
    }
191
192
    /**
193
     * @return $this
194
     */
195
    public function contains($needle): self {
196
        $this->startStep('contains "' . $needle . '"')
197
            ->assertContains($needle);
198
        return $this;
199
    }
200
201
    /**
202
     * @return $this
203
     */
204
    public function doesNotContain($needle): self {
205
        $this->startStep('does not contain "' . $needle . '"')
206
            ->assertNotContains($needle);
207
        return $this;
208
    }
209
}