for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author SignpostMarv
*/
declare(strict_types=1);
namespace SignpostMarv\DaftFramework\Tests\fixtures\Routes;
use InvalidArgumentException;
use SignpostMarv\DaftRouter\DaftRoute;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class CookieTest implements DaftRoute
{
public static function DaftRouterHandleRequest(Request $request, array $args) : Response
$resp = new Response('');
$cookie = new Cookie(
$args['name'],
$args['value'],
123,
'',
null,
'1' === $args['secure'],
'1' === $args['http'],
false,
$args['same-site']
);
$resp->headers->setCookie($cookie);
return $resp;
}
public static function DaftRouterRoutes() : array
return [
'/cookie-test/{name:[^\/]+}/{value:[^\/]+}/{secure:[0-1]}/{http:[0-1]}/{same-site:(?:lax|strict)}' => ['GET'],
];
public static function DaftRouterHttpRoute(array $args, string $method = 'GET') : string
if (
! isset(
$args['secure'],
$args['http'],
)
) {
throw new InvalidArgumentException('cookie args not specified!');
return sprintf(
'/cookie-test/%s/%s/%u/%u/%s',