<?php

declare(strict_types=1);

namespace Apexl\Io\Validation;

use Apexl\Config\ConfigurationInterface;
use Apexl\Io\HookManager;
use Apexl\Io\Interfaces\ProvidesHooksInterface;
use Apexl\Io\Module;
use Apexl\Io\Validation\Hooks\AddCustomPhpValidatorRules;
use Apexl\Io\Validation\Hooks\AddMiddleware;
use Slim\App;

final readonly class ValidationModule extends Module implements
    ProvidesHooksInterface
{

    public final const string HOOK__CUSTOM_PHP_VALIDATOR_RULES = 'validation.custom_validation_rules';

    public function __construct(
        ConfigurationInterface $config,
        private readonly HookManager $hookManager,
        App $app,
    ) {
        parent::__construct($config, $app);
    }

    public function initialise(): void
    {
        parent::initialise();

        $this->hookManager->processHook(self::HOOK__CUSTOM_PHP_VALIDATOR_RULES);
    }

    public function hooks(): array
    {
        return [
            AddMiddleware::class,
            AddCustomPhpValidatorRules::class,
        ];
    }
}
