@@ -14,11 +14,6 @@ final class Configuration implements ConfigurationInterface
1414 */
1515 public const OBJECTS_AS_ARRAYS_DEFAULT_VALUE = true ;
1616
17- /**
18- * Default value for {@see $isDetailedTypes} option.
19- */
20- public const DETAILED_TYPES_DEFAULT_VALUE = true ;
21-
2217 /**
2318 * Default value for {@see $isStrictTypes} option.
2419 */
@@ -30,32 +25,27 @@ public function __construct(
3025 * associative arrays, otherwise anonymous {@see object} will be
3126 * returned.
3227 */
33- private ?bool $ isObjectsAsArrays = null ,
34- /**
35- * If this option contains {@see true}, then all composite types will
36- * be displayed along with detailed fields/values.
37- */
38- private ?bool $ isDetailedTypes = null ,
28+ private readonly ?bool $ isObjectsAsArrays = null ,
3929 /**
4030 * If this option contains {@see true}, then strict types will
4131 * be enabled.
4232 */
43- private ?bool $ isStrictTypes = null ,
33+ private readonly ?bool $ isStrictTypes = null ,
4434 /**
4535 * If this option contains {@see LoggerInterface}, then logger
4636 * will be enabled.
4737 *
4838 * Logger will be disabled in case of argument contain {@see null}.
4939 */
50- private ?LoggerInterface $ logger = null ,
40+ private readonly ?LoggerInterface $ logger = null ,
5141 /**
5242 * If this option contains {@see TracerInterface}, then an application
5343 * tracing will be enabled using given tracer.
5444 *
5545 * An application tracing will be disabled in case of argument
5646 * contain {@see null}.
5747 */
58- private ?TracerInterface $ tracer = null ,
48+ private readonly ?TracerInterface $ tracer = null ,
5949 ) {}
6050
6151 /**
@@ -67,10 +57,12 @@ public function __construct(
6757 */
6858 public function withObjectsAsArrays (?bool $ enabled = null ): self
6959 {
70- $ self = clone $ this ;
71- $ self ->isObjectsAsArrays = $ enabled ;
72-
73- return $ self ;
60+ return new self (
61+ isObjectsAsArrays: $ enabled ,
62+ isStrictTypes: $ this ->isStrictTypes ,
63+ logger: $ this ->logger ,
64+ tracer: $ this ->tracer ,
65+ );
7466 }
7567
7668 public function isObjectsAsArrays (): bool
@@ -88,36 +80,6 @@ public function isObjectsAsArraysOptionDefined(): bool
8880 return $ this ->isObjectsAsArrays !== null ;
8981 }
9082
91- /**
92- * Enables or disables detailed types in exceptions.
93- *
94- * In case of $enabled is {@see null} a default value will be defined.
95- *
96- * @api
97- */
98- public function withDetailedTypes (?bool $ enabled = null ): self
99- {
100- $ self = clone $ this ;
101- $ self ->isDetailedTypes = $ enabled ;
102-
103- return $ self ;
104- }
105-
106- public function isDetailedTypes (): bool
107- {
108- return $ this ->isDetailedTypes ?? self ::DETAILED_TYPES_DEFAULT_VALUE ;
109- }
110-
111- /**
112- * Returns {@see true} in case option is user-defined.
113- *
114- * @api
115- */
116- public function isDetailedTypesOptionDefined (): bool
117- {
118- return $ this ->isDetailedTypes !== null ;
119- }
120-
12183 /**
12284 * Enables or disables strict types in casting.
12385 *
@@ -127,10 +89,12 @@ public function isDetailedTypesOptionDefined(): bool
12789 */
12890 public function withStrictTypes (?bool $ enabled = null ): self
12991 {
130- $ self = clone $ this ;
131- $ self ->isStrictTypes = $ enabled ;
132-
133- return $ self ;
92+ return new self (
93+ isObjectsAsArrays: $ this ->isObjectsAsArrays ,
94+ isStrictTypes: $ enabled ,
95+ logger: $ this ->logger ,
96+ tracer: $ this ->tracer ,
97+ );
13498 }
13599
136100 public function isStrictTypesEnabled (): bool
@@ -156,10 +120,12 @@ public function isStrictTypesOptionDefined(): bool
156120 */
157121 public function withLogger (?LoggerInterface $ logger = null ): self
158122 {
159- $ self = clone $ this ;
160- $ self ->logger = $ logger ;
161-
162- return $ self ;
123+ return new self (
124+ isObjectsAsArrays: $ this ->isObjectsAsArrays ,
125+ isStrictTypes: $ this ->isStrictTypes ,
126+ logger: $ logger ,
127+ tracer: $ this ->tracer ,
128+ );
163129 }
164130
165131 public function getLogger (): ?LoggerInterface
@@ -176,10 +142,12 @@ public function getLogger(): ?LoggerInterface
176142 */
177143 public function withTracer (?TracerInterface $ tracer = null ): self
178144 {
179- $ self = clone $ this ;
180- $ self ->tracer = $ tracer ;
181-
182- return $ self ;
145+ return new self (
146+ isObjectsAsArrays: $ this ->isObjectsAsArrays ,
147+ isStrictTypes: $ this ->isStrictTypes ,
148+ logger: $ this ->logger ,
149+ tracer: $ tracer ,
150+ );
183151 }
184152
185153 public function getTracer (): ?TracerInterface
0 commit comments