<?php

declare(strict_types=1);

namespace App\Http\Requests\Sanitizers;

use ArondeParon\RequestSanitizer\Contracts\Sanitizer;
use Elceka\Laravel\HashId\Facades\Hasher;

/**
 * Class HashIdSanitizer
 */
class HashIdSanitizer implements Sanitizer
{
    /**
     * @return int|string
     */
    public function sanitize(string $input)
    {
        $sanitized = Hasher::decode($input);

        if (empty($sanitized)) {
            return $input;
        }

        return $sanitized;
    }
}
