<?php

declare(strict_types=1);

namespace App\Http\Requests\Sanitizers;

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

/**
 * Class HashIdSanitizer
 *
 * @package App\Http\Requests\Sanitizers
 */
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;
    }
}
