Exemple #1
0
 private function setTimeString($input)
 {
     // HH:MM:SS, HHMMSS
     if (strlen((string) $input) > strlen('000000') && TypeUtils::isInteger($input)) {
         // unix timestamp
         list($this->hour, $this->minute, $this->second) = explode(':', date('H:i:s', $input));
     } else {
         if (preg_match('/[^\\d]/', $input)) {
             $chunks = preg_split('/[^\\d]+/', $input);
         } else {
             Assert::notImplemented('"HHMMSS" syntax not implemented in the Time parser');
         }
         $setters = array('hour', 'minute', 'second');
         foreach ($chunks as $k => $v) {
             $this->{'set' . $setters[$k]}($v);
         }
     }
 }
Exemple #2
0
 /**
  * Checks if assertion is positive integer
  * @notice Internal is_integer function is not used, special checks are provided by TypeUtils
  * @param mixed $assertion
  * @param string $message optional string to be printed when assertion check fails
  * @return void
  */
 static function isPositiveInteger($variable, $message = null)
 {
     if (!TypeUtils::isInteger($variable) || $variable < 0) {
         if (!$message) {
             $args = array('variable is expected to be positivoe integer, [%s] given', $variable);
         } else {
             $args = func_get_args();
             $args = array_slice($args, 1);
         }
         self::triggerError($args);
     }
 }
Exemple #3
0
 protected function isValidValue($value)
 {
     return parent::isValidValue($value) && TypeUtils::isInteger($value);
 }