Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/Context/Normalizer/UidNormalizerContextBuilder.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Serializer\Context\Normalizer;
13
14 use Symfony\Component\Serializer\Context\ContextBuilderInterface;
15 use Symfony\Component\Serializer\Context\ContextBuilderTrait;
16 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
17 use Symfony\Component\Serializer\Normalizer\UidNormalizer;
18
19 /**
20 * A helper providing autocompletion for available UidNormalizer options.
21 *
22 * @author Mathias Arlaud <[email protected]>
23 */
24 final class UidNormalizerContextBuilder implements ContextBuilderInterface
25 {
26 use ContextBuilderTrait;
27
28 /**
29 * Configures the uuid format for normalization.
30 *
31 * @throws InvalidArgumentException
32 */
33 public function withNormalizationFormat(?string $normalizationFormat): static
34 {
35 if (null !== $normalizationFormat && !\in_array($normalizationFormat, UidNormalizer::NORMALIZATION_FORMATS, true)) {
36 throw new InvalidArgumentException(\sprintf('The "%s" normalization format is not valid.', $normalizationFormat));
37 }
38
39 return $this->with(UidNormalizer::NORMALIZATION_FORMAT_KEY, $normalizationFormat);
40 }
41 }