<?php

declare(strict_types=1);

namespace App\Index;

final class IndexStructureComparator
{
    public function compare(?array $meta, array $profileStructure): array
    {
        $result = [];

        $keys = array_unique(
            array_merge(
                array_keys($profileStructure),
                $meta ? array_keys($meta) : []
            )
        );

        foreach ($keys as $key) {
            if (in_array($key, ['index_version', 'created_at'], true)) {
                continue;
            }

            $metaValue = $meta[$key] ?? null;
            $profileValue = $profileStructure[$key] ?? null;

            $result[$key] = [
                'meta' => $metaValue,
                'profile' => $profileValue,
                'equal' => $metaValue === $profileValue,
            ];
        }

        return $result;
    }
}
