Skip to content

Commit 4b2aa06

Browse files
committed
feat: add enableAutoCasting and disableAutoCasting functions
1 parent 09bdfd4 commit 4b2aa06

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/support/src/DataObject.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ public static function make(array $data): static
6868
return new static(...$constructorArgs);
6969
}
7070

71+
/**
72+
* Enable or disable auto-casting of data values.
73+
*/
74+
public static function enableAutoCasting(): void
75+
{
76+
static::$autoCasting = true;
77+
}
78+
79+
/**
80+
* Disable auto-casting of data values.
81+
*/
82+
public static function disableAutoCasting(): void
83+
{
84+
static::$autoCasting = false;
85+
}
86+
7187
/**
7288
* Convert the parameter name to the data key format.
7389
* It converts camelCase to snake_case by default.

0 commit comments

Comments
 (0)