<?php

namespace App\Support;

use Illuminate\Http\Request;

final class MobileUserAgent
{
    public static function matches(Request $request): bool
    {
        $userAgent = $request->userAgent();

        if ($userAgent === null || $userAgent === '') {
            return false;
        }

        return (bool) preg_match(
            '/android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile/i',
            strtolower($userAgent),
        );
    }
}
