<?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
{
    /**
     * @param  string  $input
     * @return int|string
     */
    public function sanitize($input)
    {
        $sanitized = Hasher::decode($input);

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

        return $sanitized;
    }
}
