for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Neutrino package.
*
* (c) Vasil Dakov <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace VasilDakov\Speedy\Service\Location\State;
use RuntimeException;
use InvalidArgumentException;
use Laminas\Hydrator\ReflectionHydrator;
use VasilDakov\Speedy\Model\State;
use VasilDakov\Speedy\Serializer\SerializerFactory;
/**
* Class FindStateResponseFactory
* @author Vasil Dakov <[email protected]>
* @copyright 2009-2023 Neutrino.bg
* @version 1.0
* @psalm-suppress MissingConstructor
class FindStateResponseFactory
{
public function __invoke(string $json): FindStateResponse
/** @var array $array */
$array = json_decode($json, true);
$array
if (json_last_error() !== JSON_ERROR_NONE) {
throw new InvalidArgumentException('Invalid or malformed JSON');
}
$serializer = (new SerializerFactory())();
/** @var FindStateResponse $response */
return $serializer->deserialize($json, FindStateResponse::class, 'json');