1
0
mirror of synced 2024-12-01 09:06:03 +03:00
service-bundle/ArgumentResolver/AbstractValueResolver.php
Кривич Сергей f591629786 Update value resolvers
2022-07-20 13:51:43 +03:00

27 lines
685 B
PHP

<?php
namespace RetailCrm\ServiceBundle\ArgumentResolver;
use RetailCrm\ServiceBundle\Exceptions\InvalidRequestArgumentException;
use Symfony\Component\Validator\Validator\ValidatorInterface;
abstract class AbstractValueResolver
{
public function __construct(
protected ValidatorInterface $validator)
{
}
protected function validate(object $data): void
{
$errors = $this->validator->validate($data);
if (0 !== count($errors)) {
throw new InvalidRequestArgumentException(
sprintf("Invalid request parameter %s", \get_class($data)),
400,
$errors
);
}
}
}