/** * Test validate intlike. */ public function test_validate_intlike() { $invalid = array(true, false, null, array(), new \stdClass(), 1.4, '1.5'); foreach ($invalid as $i => $val) { $this->assertEquals(false, \pdyn\datatype\Validator::intlike($val), 'failed for test ' . $i); } $valid = array(1, 0, '0', '1', -1, '-1'); foreach ($valid as $val) { $this->assertEquals(true, \pdyn\datatype\Validator::intlike($val)); } }
/** * Set the number of tiems per page. * * @param int $perpage The number of items per page to set. */ public function set_items_per_page($perpage) { $this->perpage = !empty($perpage) && \pdyn\datatype\Validator::intlike($perpage) ? (int) $perpage : 20; }
/** * Validate datatype. * * @param mixed $input Value to validate. * @return bool Value is valid or not. */ public static function validate($input) { return \pdyn\datatype\Validator::intlike($input) && (int) $input >= 0; }
/** * Create a thumbnail for the image based on a maximum x and maximum y value. * * @param int $maxx Maximum x dimension. * @param int $maxy Maximum y dimension. * @return bool Success/Failure. */ public function thumbnail($maxx, $maxy) { if ($maxx !== null && \pdyn\datatype\Validator::intlike($maxx) !== true) { throw new \Exception('Invalid maxx parameter in \\pdyn\\image\\Image', static::ERR_BAD_INPUT); } if ($maxy !== null && \pdyn\datatype\Validator::intlike($maxy) !== true) { throw new \Exception('Invalid maxy parameter in \\pdyn\\image\\Image', static::ERR_BAD_INPUT); } // Fix orientation. $imageinfo = $this->get_info(); if ($imageinfo['orientation'] !== 1) { $this->transform_for_exif_orientation($imageinfo['orientation']); } $this->bounded_resize((int) $maxx, (int) $maxy); return true; }