Code Duplication    Length = 12-16 lines in 3 locations

src/JsonLd/Serializer/ContextTrait.php 1 location

@@ 33-45 (lines=13) @@
30
     *
31
     * @return array
32
     */
33
    private function createContext(string $resourceClass, array $context) : array
34
    {
35
        if (isset($context['jsonld_has_context'])) {
36
            return $context;
37
        }
38
39
        return array_merge($context, [
40
            'jsonld_has_context' => true,
41
            // Don't use hydra:Collection in sub levels
42
            'jsonld_sub_level' => true,
43
            'resource_class' => $resourceClass,
44
        ]);
45
    }
46
47
    /**
48
     * Updates the given JSON-LD document to add its @context key.

src/Serializer/ContextTrait.php 2 locations

@@ 54-65 (lines=12) @@
51
     *
52
     * @return array
53
     */
54
    private function createHalContext(string $resourceClass, array $context) : array
55
    {
56
        if (isset($context['jsonhal_has_context'])) {
57
            return $context;
58
        }
59
60
        return array_merge($context, [
61
            'jsonhal_has_context' => true,
62
            'jsonhal_sub_level' => true,
63
            'resource_class' => $resourceClass,
64
        ]);
65
    }
66
67
    /**
68
     * Import the context defined in metadata and set some default values.
@@ 75-90 (lines=16) @@
72
     *
73
     * @return array
74
     */
75
    private function createJsonLdContext(string $resourceClass, array $context) : array
76
    {
77
        if (isset($context['jsonld_has_context'])) {
78
            return $context;
79
        }
80
81
        return array_merge(
82
            $context,
83
            [
84
                'jsonld_has_context' => true,
85
                // Don't use hydra:Collection in sub levels
86
                'jsonld_sub_level' => true,
87
                'resource_class' => $resourceClass,
88
            ]
89
        );
90
    }
91
92
    /**
93
     * Updates the given document to add its keys.