private function getAlgoliaRecordsFromSearchableModelArray(array $searchableModels)
    {
        if (empty($searchableModels)) {
            throw new \InvalidArgumentException('The given array should not be empty');
        }

        // Use the first element of the array to define what kind of models we are indexing.
        $arrayType = \get_class($searchableModels[0]);
        $this->checkImplementsSearchableInterface($arrayType);

        return \array_map(function (SearchableInterface $searchableModel) use ($arrayType) {
            if (! $searchableModel instanceof $arrayType) {
                throw new \InvalidArgumentException('The given array should not contain multiple different classes');
            }

            $algoliaRecord = $searchableModel->getAlgoliaRecord();
            $algoliaRecord['objectID'] = $searchableModel->getObjectID();

            return $algoliaRecord;
        }, $searchableModels);
    }