<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Uid\Uuid;
class MobileController extends AbstractController
{
#[Route('/mobile', name: 'app_mobile', methods: ['GET'])]
public function index(Request $request): Response
{
return $this->render('mobile/mobile.html.twig', [
'site_name' => 'First ID Demo'
]);
}
#[Route('/mobile/generate-maid', name: 'app_generate_maid', methods: ['GET'])]
public function generateMaid(): JsonResponse
{
$maid = Uuid::v4()->toRfc4122();
return new JsonResponse(['maid' => $maid]);
}
#[Route('/mobile/generate-email', name: 'app_generate_email', methods: ['GET'])]
public function generateEmail(): JsonResponse
{
$randomEmail = 'user' . rand(1000, 9999) . '@example.com';
return new JsonResponse(['email' => $randomEmail]);
}
#[Route('/mobile/generate-config', name: 'app_generate_config', methods: ['GET'])]
public function generateConfig(): JsonResponse
{
$config = [
'deviceType' => ['web', 'mobile', 'tablet'][array_rand(['web', 'mobile', 'tablet'])],
'deviceManufacturer' => ['Apple', 'Samsung', 'Google', 'Dell', 'HP'][array_rand(['Apple', 'Samsung', 'Google', 'Dell', 'HP'])],
'osVersion' => rand(10, 15) . '.' . rand(0, 9) . '.' . rand(0, 9),
'buildId' => 'Build_' . bin2hex(random_bytes(4)),
'deviceModel' => ['iPhone 12', 'Galaxy S21', 'Pixel 5', 'XPS 13', 'Spectre x360'][array_rand(['iPhone 12', 'Galaxy S21', 'Pixel 5', 'XPS 13', 'Spectre x360'])],
'deviceResolution' => rand(720, 3840) . 'x' . rand(480, 2160),
'deviceRam' => rand(2, 32) * 1024
];
return new JsonResponse(['config' => $config]);
}
}