Example #1
0
 public function validates()
 {
     if ($this->input->getValue()) {
         return Integer::isNummeric($this->input->getValue());
     }
     return true;
 }
Example #2
0
 public function validates()
 {
     if ($this->input->getValue()) {
         if (!Integer::isInteger($this->input->getValue())) {
             $this->error = lang('%s is not a valid number', $this->input->getName());
         }
         if ($this->input->getValue() > $this->maxValue) {
             $this->error = lang('%s cannot be greater than %s', $this->input->getName(), $this->maxValue);
         }
         return !$this->error;
     }
     return true;
 }
Example #3
0
 /**
  * Escapes query and formats it with arguments
  * @param string $query
  * @param array|null $args
  * @return string
  */
 public static function formatQuery($query, $args = null)
 {
     if (is_array($args) && count($args) > 0) {
         $a = [];
         foreach ($args as $arg) {
             if (is_null($arg)) {
                 $a[] = 'null';
             } elseif (Integer::isInteger($arg)) {
                 $a[] = sprintf("%s", self::escape($arg));
             } else {
                 $a[] = sprintf("'%s'", self::escape($arg));
             }
         }
         if (count($a) > 0 && $query) {
             return vsprintf($query, $a);
         }
     }
     return $query;
 }
Example #4
0
 protected function parseArrayData($data)
 {
     if (is_array($data)) {
         $out = [];
         foreach ($data as $d) {
             $out[] = $this->parseArrayData($d);
         }
         return $out;
     }
     $data = !is_array($data) && !mb_detect_encoding($data, 'UTF-8', true) ? utf8_encode($data) : $data;
     return Integer::isInteger($data) ? intval($data) : $data;
 }