StringMatcher   A
last analyzed

Complexity

Total Complexity 22

Size/Duplication

Total Lines 219
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 67
c 1
b 0
f 0
dl 0
loc 219
rs 10
wmc 22

22 Methods

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