Code Duplication    Length = 25-25 lines in 2 locations

src/Negotiation/AcceptLanguageNegotiator.php 1 location

@@ 52-76 (lines=25) @@
49
     *
50
     * @return array
51
     */
52
    private function aggregatedValues(string $header): array
53
    {
54
        $values = [];
55
        foreach (explode(',', $header) as $headerValue) {
56
            $headerValueParts = explode(';', $headerValue);
57
            $locale = trim(array_shift($headerValueParts));
58
            $attributes = [];
59
            foreach ($headerValueParts as $attribute) {
60
                list($attributeKey, $attributeValue) = explode('=', $attribute);
61
                $attributes[trim($attributeKey)] = trim($attributeValue);
62
            }
63
64
            if (!isset($attributes['q'])) {
65
                $attributes['q'] = '1.0';
66
            }
67
68
            $values[$locale] = $attributes;
69
        }
70
71
        uasort($values, function (array $a, array $b) {
72
            return $b['q'] <=> $a['q'];
73
        });
74
75
        return $values;
76
    }
77
78
    /**
79
     * @param array $aggregatedValues

src/Negotiation/AcceptNegotiator.php 1 location

@@ 52-76 (lines=25) @@
49
     *
50
     * @return array
51
     */
52
    private function aggregatedValues(string $header): array
53
    {
54
        $values = [];
55
        foreach (explode(',', $header) as $headerValue) {
56
            $headerValueParts = explode(';', $headerValue);
57
            $mediaType = trim(array_shift($headerValueParts));
58
            $attributes = [];
59
            foreach ($headerValueParts as $attribute) {
60
                list($attributeKey, $attributeValue) = explode('=', $attribute);
61
                $attributes[trim($attributeKey)] = trim($attributeValue);
62
            }
63
64
            if (!isset($attributes['q'])) {
65
                $attributes['q'] = '1.0';
66
            }
67
68
            $values[$mediaType] = $attributes;
69
        }
70
71
        uasort($values, function (array $a, array $b) {
72
            return $b['q'] <=> $a['q'];
73
        });
74
75
        return $values;
76
    }
77
78
    /**
79
     * @param array $aggregatedValues