/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/ObjectMapper/Tests/Fixtures/ServiceLoadedValue/ServiceLoadedValueTransformer.php
39 строк
1 KB
Ryan RAJKOMAR
[ObjectMapper] Allow class FQDN arrays as TargetClass and SourceClass param
06 мар 2026, 18:16
06 мар 2026, 18:16
bf07ee6
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ObjectMapper\Tests\Fixtures\ServiceLoadedValue; use Symfony\Component\ObjectMapper\Metadata\ObjectMapperMetadataFactoryInterface; use Symfony\Component\ObjectMapper\TransformCallableInterface; /** * @implements TransformCallableInterface<object,object> */ class ServiceLoadedValueTransformer implements TransformCallableInterface { public function __construct(private readonly LoadedValueService $serviceLoadedValue, private readonly ObjectMapperMetadataFactoryInterface $metadata) { } public function __invoke(mixed $value, object $source, ?object $target): mixed { $metadata = $this->metadata->create($value); if (1 !== \count($metadata)) { throw new \LogicException('Exactly one metadata should be returned.'); } if (LoadedValue::class !== $metadata[0]->target) { throw new \LogicException('The target should be '.LoadedValue::class.'.'); } return $this->serviceLoadedValue->get(); } }