automatewoo/includes/Traits/IntegerValidator.php
fei-source 47d3c9a8b6 Update to v6.2.2
Source: GrootMade/Festinger Vault
2026-03-15 08:31:15 +08:00

26 lines
509 B
PHP

<?php
namespace AutomateWoo\Traits;
use AutomateWoo\Exceptions\InvalidArgument;
/**
* IntegerValidator trait.
*
* @since 5.1.0
*/
trait IntegerValidator {
/**
* Validate that an value is a positive integer.
*
* @param mixed $value The value to validate.
*
* @throws InvalidArgument When $value is not valid.
*/
public function validate_positive_integer( $value ) {
if ( ! is_int( $value ) || $value <= 0 ) {
throw InvalidArgument::invalid_argument( 'a positive integer' );
}
}
}