Code Duplication    Length = 12-14 lines in 2 locations

lib/Elastica/Type.php 1 location

@@ 316-327 (lines=12) @@
313
     *
314
     * @return array Current mapping
315
     */
316
    public function getMapping()
317
    {
318
        $response = $this->requestEndpoint(new Get());
319
        $data = $response->getData();
320
321
        $mapping = array_shift($data);
322
        if (isset($mapping['mappings'])) {
323
            return $mapping['mappings'];
324
        }
325
326
        return [];
327
    }
328
329
    /**
330
     * Create search object.

lib/Elastica/Index.php 1 location

@@ 95-108 (lines=14) @@
92
     *
93
     * @return array
94
     */
95
    public function getMapping()
96
    {
97
        $response = $this->requestEndpoint(new Get());
98
        $data = $response->getData();
99
100
        // Get first entry as if index is an Alias, the name of the mapping is the real name and not alias name
101
        $mapping = array_shift($data);
102
103
        if (isset($mapping['mappings'])) {
104
            return $mapping['mappings'];
105
        }
106
107
        return [];
108
    }
109
110
    /**
111
     * Returns the index settings object.