for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Jerowork\RouteAttributeProvider\RouteLoader\Cache;
use Generator;
use Jerowork\RouteAttributeProvider\RouteLoader\LoadedRoute;
use JsonException;
trait MapCachePayloadToLoadedRoutesTrait
{
/**
* @return Generator<LoadedRoute>
*
* @throws JsonException
*/
public function mapCachePayloadToLoadedRoutes(mixed $payload): Generator
yield from array_map(
static fn (array $payload): LoadedRoute => LoadedRoute::fromPayload($payload),
json_decode($payload, true, flags: JSON_THROW_ON_ERROR)
);
}