diff --git a/src/IsMigrationDataTransferObject.php b/src/IsMigrationDataTransferObject.php index da674a7..33d10a4 100644 --- a/src/IsMigrationDataTransferObject.php +++ b/src/IsMigrationDataTransferObject.php @@ -14,6 +14,17 @@ trait IsMigrationDataTransferObject { use ForwardsCalls; + /** @var list */ + private static array $missingValues = []; + + /** + * @param list $values + */ + public static function treatAsMissing(array $values): void + { + self::$missingValues = $values; + } + /** * @deprecated */ @@ -127,7 +138,8 @@ protected function has(string $key): bool { $this->assertFieldExists($key); - return (new ReflectionProperty(static::class, $this->keyToProperty($key)))->isInitialized($this); + return (new ReflectionProperty(static::class, $this->keyToProperty($key)))->isInitialized($this) && + !in_array($this->{$this->keyToProperty($key)}, self::$missingValues, true); } /**