Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/Context/Encoder/JsonEncoderContextBuilder.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\Encoder;
13
14 use Symfony\Component\Serializer\Context\ContextBuilderInterface;
15 use Symfony\Component\Serializer\Context\ContextBuilderTrait;
16 use Symfony\Component\Serializer\Encoder\JsonDecode;
17 use Symfony\Component\Serializer\Encoder\JsonEncode;
18
19 /**
20 * A helper providing autocompletion for available JsonEncoder options.
21 *
22 * @author Mathias Arlaud <[email protected]>
23 */
24 final class JsonEncoderContextBuilder implements ContextBuilderInterface
25 {
26 use ContextBuilderTrait;
27
28 /**
29 * Configures the json_encode flags bitmask.
30 *
31 * @see https://php.net/json.constants
32 *
33 * @param positive-int|null $options
34 */
35 public function withEncodeOptions(?int $options): static
36 {
37 return $this->with(JsonEncode::OPTIONS, $options);
38 }
39
40 /**
41 * Configures the json_decode flags bitmask.
42 *
43 * @see https://php.net/json.constants
44 *
45 * @param positive-int|null $options
46 */
47 public function withDecodeOptions(?int $options): static
48 {
49 return $this->with(JsonDecode::OPTIONS, $options);
50 }
51
52 /**
53 * Configures whether decoded objects will be given as
54 * associative arrays or as nested stdClass.
55 */
56 public function withAssociative(?bool $associative): static
57 {
58 return $this->with(JsonDecode::ASSOCIATIVE, $associative);
59 }
60
61 /**
62 * Configures the maximum recursion depth.
63 *
64 * Must be strictly positive.
65 *
66 * @param positive-int|null $recursionDepth
67 */
68 public function withRecursionDepth(?int $recursionDepth): static
69 {
70 return $this->with(JsonDecode::RECURSION_DEPTH, $recursionDepth);
71 }
72 }