Code Duplication    Length = 15-18 lines in 2 locations

src/PhpUnit/HeadersConstraint.php 1 location

@@ 43-57 (lines=15) @@
40
            throw new UnexpectedValueException('Array expected');
41
        }
42
43
        foreach ($this->expectedHeadersSchemas as $name => $expectedSchema) {
44
            if (isset($actualHeaders[$name])) {
45
                $errors = $this->validator->validate(
46
                    $this->normalizeHeaderValue($actualHeaders[$name], $expectedSchema->type),
47
                    $expectedSchema,
48
                    new JsonPointer("#/{$name}")
49
                );
50
                $this->errors = array_merge($this->errors, $errors);
51
            } elseif (isset($expectedSchema->required) && $expectedSchema->required) {
52
                $this->errors[] = [
53
                    'property' => $name,
54
                    'message' => "Missing required header ({$name})",
55
                ];
56
            }
57
        }
58
59
        return empty($this->errors);
60
    }

src/PhpUnit/UriConstraint.php 1 location

@@ 128-145 (lines=18) @@
125
        parse_str($uri->getQuery(), $actualQueryParams);
126
127
        // TODO: Assert query params
128
        foreach ($this->queryParameters as $name => $queryParamSchema) {
129
            if (isset($actualQueryParams[$name])) {
130
                $actualQueryParam = $actualQueryParams[$name];
131
132
                // TODO: Consider to disallow non-string params in query, that make no sense
133
                $actualQueryParam = $this->normalizeNumericString($actualQueryParam);
134
135
                $this->errors = array_merge(
136
                    $this->errors,
137
                    $this->validator->validate($actualQueryParam, $queryParamSchema, new JsonPointer('#/query'))
138
                );
139
            } elseif (isset($queryParamSchema->required) && $queryParamSchema->required) {
140
                $this->errors[] = [
141
                    'property' => 'query',
142
                    'message' => "Missing required query param ({$name})",
143
                ];
144
            }
145
        }
146
147
        return empty($this->errors);
148
    }