Code Duplication    Length = 15-18 lines in 2 locations

src/PhpUnit/HeadersConstraint.php 1 location

@@ 56-70 (lines=15) @@
53
            throw new UnexpectedValueException('Array expected');
54
        }
55
56
        foreach ($this->expectedHeadersSchemas as $name => $expectedSchema) {
57
            if (isset($actualHeaders[$name])) {
58
                $errors = $this->validator->validate(
59
                    $this->normalizeHeaderValue($actualHeaders[$name]),
60
                    $expectedSchema,
61
                    $name
62
                );
63
                $this->errors = array_merge($this->errors, $errors);
64
            } elseif (isset($expectedSchema->required) && $expectedSchema->required) {
65
                $this->errors[] = [
66
                    'property' => $name,
67
                    'message' => "Missing required header ({$name})",
68
                ];
69
            }
70
        }
71
72
        return empty($this->errors);
73
    }

src/PhpUnit/UriConstraint.php 1 location

@@ 160-177 (lines=18) @@
157
        parse_str($uri->getQuery(), $actualQueryParams);
158
159
        // TODO: Assert query params
160
        foreach ($this->queryParams as $name => $queryParamSchema) {
161
            if (isset($actualQueryParams[$name])) {
162
                $actualQueryParam = $actualQueryParams[$name];
163
164
                // TODO: Consider to disallow non-string params in query, that make no sense
165
                $actualQueryParam = $this->normalizeNumericString($actualQueryParam);
166
167
                $this->errors = array_merge(
168
                    $this->errors,
169
                    $this->validator->validate($actualQueryParam, $queryParamSchema, 'query')
170
                );
171
            } elseif (isset($queryParamSchema->required) && $queryParamSchema->required) {
172
                $this->errors[] = [
173
                    'property' => 'query',
174
                    'message' => "Missing required query param ({$name})",
175
                ];
176
            }
177
        }
178
179
        return empty($this->errors);
180
    }