<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\DI\Compiler\Factory;

final class FactoryClassName
{
    public static function fromServiceId(string $serviceId): string
    {
        $name = preg_replace('/[^A-Za-z0-9_]/', '_', $serviceId) ?: 'service';
        $name = trim($name, '_');
        if ($name === '') {
            $name = 'service';
        }

        return 'CompiledFactory_' . md5($serviceId) . '_' . $name;
    }
}
