You are here

function pet_is_natural in Previewable email templates 8

Same name and namespace in other branches
  1. 8.4 pet.module \pet_is_natural()
  2. 6 pet.admin.inc \pet_is_natural()
  3. 7 includes/pet.admin.inc \pet_is_natural()

Return TRUE if a $val is a natural number (integer 1, 2, 3, ...).

Base can be changed to zero if desired.

1 call to pet_is_natural()
PetPreviewForm::buildForm in src/Form/PetPreviewForm.php
Form constructor.

File

./pet.module, line 359
Previewable Email Template module.

Code

function pet_is_natural($val, $base = 1) {
  if (!isset($val)) {
    return FALSE;
  }
  $return = (string) $val === (string) (int) $val;
  if ($return && intval($val) < $base) {
    $return = FALSE;
  }
  return $return;
}