Code Duplication    Length = 15-18 lines in 2 locations

src/PhpUnit/HeadersConstraint.php 1 location

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

src/PhpUnit/UriConstraint.php 1 location

@@ 110-127 (lines=18) @@
107
        parse_str($uri->getQuery(), $actualQueryParams);
108
109
        // TODO: Assert query params
110
        foreach ($this->queryParameters as $name => $queryParamSchema) {
111
            if (isset($actualQueryParams[$name])) {
112
                $actualQueryParam = $actualQueryParams[$name];
113
114
                // TODO: Consider to disallow non-string params in query, that make no sense
115
                $actualQueryParam = $this->normalizeNumericString($actualQueryParam);
116
117
                $this->errors = array_merge(
118
                    $this->errors,
119
                    $this->validator->validate($actualQueryParam, $queryParamSchema, new JsonPointer('#/query'))
120
                );
121
            } elseif (isset($queryParamSchema->required) && $queryParamSchema->required) {
122
                $this->errors[] = [
123
                    'property' => 'query',
124
                    'message' => "Missing required query param ({$name})",
125
                ];
126
            }
127
        }
128
129
        return empty($this->errors);
130
    }