Skip to content

Commit 133cf08

Browse files
authored
feat: add integer method to deserializes value trait (#44)
1 parent 4b6f56e commit 133cf08

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Filters/Concerns/DeserializesValue.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ public function asBoolean(): self
4949
return $this;
5050
}
5151

52+
/**
53+
* Deserialize value as a integer.
54+
*
55+
* @return $this
56+
*/
57+
public function asInteger(): self
58+
{
59+
$this->deserializeUsing(
60+
static fn($value) => filter_var($value, FILTER_VALIDATE_INT)
61+
);
62+
63+
return $this;
64+
}
65+
5266
/**
5367
* Deserialize the value.
5468
*

0 commit comments

Comments
 (0)