<?php

namespace App\Support;

class TenantResolver
{
    public function resolveFromHost(string $host): ?array
    {
        $parts = explode('.', $host);

        if (count($parts) < 3) {
            return null;
        }

        $tenantKey = $parts[0];

        if ($tenantKey === 'www' || $tenantKey === 'app') {
            return null;
        }

        return [
            'tenant_id' => null,
            'tenant_key' => $tenantKey,
        ];
    }
}
