1010final class Configuration
1111{
1212 /**
13- * Default value for {@see $isObjectsAsArrays } option.
13+ * Default value for {@see $objectAsArray } option.
1414 */
15- public const OBJECTS_AS_ARRAYS_DEFAULT_VALUE = true ;
15+ public const DEFAULT_OBJECT_AS_ARRAY_OPTION = true ;
1616
1717 /**
18- * Default value for {@see $isStrictTypes } option.
18+ * Default value for {@see $strictTypes } option.
1919 */
20- public const STRICT_TYPES_DEFAULT_VALUE = true ;
20+ public const DEFAULT_STRICT_TYPES_OPTION = true ;
21+
22+ /**
23+ * Default value for {@see $typeSpecifiers} option.
24+ */
25+ public const DEFAULT_TYPE_SPECIFIERS_OPTION = true ;
2126
2227 public function __construct (
2328 /**
2429 * If this option contains {@see true}, then objects are converted to
2530 * associative arrays, otherwise anonymous {@see object} will be
2631 * returned.
2732 */
28- private readonly ?bool $ isObjectsAsArrays = null ,
33+ private readonly ?bool $ objectAsArray = null ,
2934 /**
3035 * If this option contains {@see true}, then strict types will
3136 * be enabled.
3237 */
33- private readonly ?bool $ isStrictTypes = null ,
38+ private readonly ?bool $ strictTypes = null ,
39+ /**
40+ * If this option contains {@see true}, then type specifiers will
41+ * be applied.
42+ */
43+ private readonly ?bool $ typeSpecifiers = null ,
3444 /**
3545 * If this option contains {@see LoggerInterface}, then logger
3646 * will be enabled.
@@ -55,11 +65,12 @@ public function __construct(
5565 *
5666 * @api
5767 */
58- public function withObjectsAsArrays (?bool $ enabled = null ): self
68+ public function withObjectAsArray (?bool $ enabled = null ): self
5969 {
6070 return new self (
61- isObjectsAsArrays: $ enabled ,
62- isStrictTypes: $ this ->isStrictTypes ,
71+ objectAsArray: $ enabled ,
72+ strictTypes: $ this ->strictTypes ,
73+ typeSpecifiers: $ this ->typeSpecifiers ,
6374 logger: $ this ->logger ,
6475 tracer: $ this ->tracer ,
6576 );
@@ -73,18 +84,18 @@ public function withObjectsAsArrays(?bool $enabled = null): self
7384 */
7485 public function isObjectAsArray (): bool
7586 {
76- return $ this ->isObjectsAsArrays
77- ?? self ::OBJECTS_AS_ARRAYS_DEFAULT_VALUE ;
87+ return $ this ->objectAsArray
88+ ?? self ::DEFAULT_OBJECT_AS_ARRAY_OPTION ;
7889 }
7990
8091 /**
8192 * Returns {@see true} in case option is user-defined.
8293 *
8394 * @api
8495 */
85- public function isObjectsAsArraysOptionDefined (): bool
96+ public function isObjectAsArrayOptionDefined (): bool
8697 {
87- return $ this ->isObjectsAsArrays !== null ;
98+ return $ this ->objectAsArray !== null ;
8899 }
89100
90101 /**
@@ -97,8 +108,9 @@ public function isObjectsAsArraysOptionDefined(): bool
97108 public function withStrictTypes (?bool $ enabled = null ): self
98109 {
99110 return new self (
100- isObjectsAsArrays: $ this ->isObjectsAsArrays ,
101- isStrictTypes: $ enabled ,
111+ objectAsArray: $ this ->objectAsArray ,
112+ strictTypes: $ enabled ,
113+ typeSpecifiers: $ this ->typeSpecifiers ,
102114 logger: $ this ->logger ,
103115 tracer: $ this ->tracer ,
104116 );
@@ -113,8 +125,8 @@ public function withStrictTypes(?bool $enabled = null): self
113125 */
114126 public function isStrictTypesEnabled (): bool
115127 {
116- return $ this ->isStrictTypes
117- ?? self ::STRICT_TYPES_DEFAULT_VALUE ;
128+ return $ this ->strictTypes
129+ ?? self ::DEFAULT_STRICT_TYPES_OPTION ;
118130 }
119131
120132 /**
@@ -124,7 +136,45 @@ public function isStrictTypesEnabled(): bool
124136 */
125137 public function isStrictTypesOptionDefined (): bool
126138 {
127- return $ this ->isStrictTypes !== null ;
139+ return $ this ->strictTypes !== null ;
140+ }
141+
142+ /**
143+ * Enables or disables type specifiers while casting.
144+ *
145+ * In case of $enabled is {@see null} a default value will be defined.
146+ *
147+ * @api
148+ */
149+ public function withTypeSpecifiers (?bool $ enabled = null ): self
150+ {
151+ return new self (
152+ objectAsArray: $ this ->objectAsArray ,
153+ strictTypes: $ this ->strictTypes ,
154+ typeSpecifiers: $ enabled ,
155+ logger: $ this ->logger ,
156+ tracer: $ this ->tracer ,
157+ );
158+ }
159+
160+ /**
161+ * In case of method returns {@see true}, all types will be checked
162+ * for additional assertions.
163+ */
164+ public function isTypeSpecifiersEnabled (): bool
165+ {
166+ return $ this ->typeSpecifiers
167+ ?? self ::DEFAULT_TYPE_SPECIFIERS_OPTION ;
168+ }
169+
170+ /**
171+ * Returns {@see true} in case option is user-defined.
172+ *
173+ * @api
174+ */
175+ public function isTypeSpecifierOptionDefined (): bool
176+ {
177+ return $ this ->typeSpecifiers !== null ;
128178 }
129179
130180 /**
@@ -136,8 +186,9 @@ public function isStrictTypesOptionDefined(): bool
136186 public function withLogger (?LoggerInterface $ logger = null ): self
137187 {
138188 return new self (
139- isObjectsAsArrays: $ this ->isObjectsAsArrays ,
140- isStrictTypes: $ this ->isStrictTypes ,
189+ objectAsArray: $ this ->objectAsArray ,
190+ strictTypes: $ this ->strictTypes ,
191+ typeSpecifiers: $ this ->typeSpecifiers ,
141192 logger: $ logger ,
142193 tracer: $ this ->tracer ,
143194 );
@@ -162,8 +213,9 @@ public function findLogger(): ?LoggerInterface
162213 public function withTracer (?TracerInterface $ tracer = null ): self
163214 {
164215 return new self (
165- isObjectsAsArrays: $ this ->isObjectsAsArrays ,
166- isStrictTypes: $ this ->isStrictTypes ,
216+ objectAsArray: $ this ->objectAsArray ,
217+ strictTypes: $ this ->strictTypes ,
218+ typeSpecifiers: $ this ->typeSpecifiers ,
167219 logger: $ this ->logger ,
168220 tracer: $ tracer ,
169221 );
0 commit comments