Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/Field/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,20 @@ class Number extends \Geniem\ACF\Field {
/**
* Set step size
*
* @param integer $step Step size.
* @param integer|float $step Step size.
* @return self
*/
public function set_step( int $step ) {
public function set_step( $step ) {
// Validate that the step is an integer or a float
if ( ! is_int( $step ) && ! is_float( $step ) ) {
throw new \Geniem\ACF\Exception( 'Geniem\ACF\Field\Number: set_step() only accepts integers or floats' );
}

// Ensure the step is positive
if ( $step <= 0 ) {
throw new \Geniem\ACF\Exception( 'Geniem\ACF\Field\Number: set_step() only accepts positive values' );
}

$this->step = $step;

return $this;
Expand All @@ -54,7 +64,7 @@ public function set_step( int $step ) {
/**
* Get step size
*
* @return integer
* @return integer|float
*/
public function get_step() {
return $this->step;
Expand Down