Code Duplication    Length = 14-18 lines in 2 locations

eZ/Publish/Core/REST/Server/Output/ValueObjectVisitor/CachedValue.php 1 location

@@ 59-76 (lines=18) @@
56
            }
57
        }
58
59
        if (!empty($data->cacheTags)) {
60
            // See doc/specifications/cache/multi_tagging.md
61
            $tags = [];
62
            foreach ($data->cacheTags as $tag => $values) {
63
                foreach ((array)$values as $value) {
64
                    $tagValue = $tag . '-' . $value;
65
                    if (!$response->headers->contains('xkey', $tagValue)) {
66
                        $tags[] = $tag . '-' . $value;
67
                    }
68
                }
69
            }
70
71
            $response->headers->set(
72
                'xkey',
73
                $tags,
74
                false
75
            );
76
        }
77
    }
78
79
    public function getParameter($parameterName, $defaultValue = null)

eZ/Publish/Core/REST/Server/Output/ValueObjectVisitor/ResourceLink.php 1 location

@@ 94-107 (lines=14) @@
91
     */
92
    private function processCachedValue(Values\CachedValue $cachedValue, Visitor $visitor)
93
    {
94
        if (!empty($cachedValue->cacheTags)) {
95
            $response = $visitor->getResponse();
96
            $tags = [];
97
            foreach ($cachedValue->cacheTags as $tag => $values) {
98
                foreach ((array)$values as $value) {
99
                    $tagValue = $tag . '-' . $value;
100
101
                    if (!$response->headers->contains('xkey', $tagValue)) {
102
                        $tags[] = $tagValue;
103
                    }
104
                }
105
            }
106
            $response->headers->set('xkey', $tags, false);
107
        }
108
109
        return $cachedValue->value;
110
    }