Skip to content

Commit c8d54e7

Browse files
committed
refactor(MapperOptions): Simplify option names.
1 parent 85527c2 commit c8d54e7

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* feat(`ObjectToObjectTransformer`): Option to disable target value reading.
1212
* refactor(`MainTransformer`): Make manual GC interval a static variable.
1313
* refactor(`ObjectToObjectMetadataFactory`): Remove `Context`.
14+
* refactor(`MapperOptions`): Simplify option names.
1415

1516
## 0.7.3
1617

src/Context/MapperOptions.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
final readonly class MapperOptions
2020
{
2121
/**
22-
* @param boolean $enableLazyLoading Enable or disable lazy loading.
23-
* @param boolean $enableTargetValueReading If disabled, values on the target side will not be read, and assumed to be null.
22+
* @param boolean $lazyLoading Enable or disable lazy loading.
23+
* @param boolean $readTargetValue If disabled, values on the target side will not be read, and assumed to be null.
2424
*/
2525
public function __construct(
26-
public bool $enableLazyLoading = true,
27-
public bool $enableTargetValueReading = true,
26+
public bool $lazyLoading = true,
27+
public bool $readTargetValue = true,
2828
) {
2929
}
3030
}

src/Transformer/ObjectToObjectTransformer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function transform(
112112

113113
if (
114114
$objectToObjectMetadata->isTargetReadOnly()
115-
|| !$context(MapperOptions::class)?->enableTargetValueReading
115+
|| !$context(MapperOptions::class)?->readTargetValue
116116
) {
117117
$target = null;
118118
}
@@ -121,7 +121,7 @@ public function transform(
121121

122122
if (null === $target) {
123123
$canUseTargetProxy = $objectToObjectMetadata->canUseTargetProxy()
124-
&& $context(MapperOptions::class)?->enableLazyLoading;
124+
&& $context(MapperOptions::class)?->lazyLoading;
125125

126126
if ($canUseTargetProxy) {
127127
$target = $this->instantiateTargetProxy(
@@ -522,7 +522,7 @@ private function transformValue(
522522

523523
if (
524524
is_object($target)
525-
&& $context(MapperOptions::class)?->enableTargetValueReading
525+
&& $context(MapperOptions::class)?->readTargetValue
526526
) {
527527
// if this is for a property mapping, not a constructor argument
528528

tests/IntegrationTest/LazyObjectTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testEagerAndLazyPropertyInConstruct(): void
118118

119119
public function testEnablingLazyObject(): void
120120
{
121-
$options = new MapperOptions(enableLazyLoading: true);
121+
$options = new MapperOptions(lazyLoading: true);
122122
$context = Context::create($options);
123123

124124
$source = new ObjectWithScalarProperties();
@@ -128,7 +128,7 @@ public function testEnablingLazyObject(): void
128128

129129
public function testDisablingLazyObject(): void
130130
{
131-
$options = new MapperOptions(enableLazyLoading: false);
131+
$options = new MapperOptions(lazyLoading: false);
132132
$context = Context::create($options);
133133

134134
$source = new ObjectWithScalarProperties();

0 commit comments

Comments
 (0)