Lazer\Classes\Helpers\Validate::isNumeric PHP Method

isNumeric() public static method

Checking that field type is numeric
public static isNumeric ( string $type ) : boolean
$type string
return boolean
    public static function isNumeric($type)
    {
        $defined = array('integer', 'double');
        if (in_array($type, $defined)) {
            return TRUE;
        }
        return FALSE;
    }

Usage Example

Esempio n. 1
0
 /**
  * Add new fields to table, array schema like in create() function
  * @param array $fields Associative array
  */
 public function addFields(array $fields)
 {
     $fields = Helpers\Validate::arrToLower($fields);
     Helpers\Validate::types(array_values($fields));
     $schema = $this->schema();
     $fields = array_diff_assoc($fields, $schema);
     if (!empty($fields)) {
         $config = $this->config();
         $config->schema = array_merge($schema, $fields);
         $data = $this->getData();
         foreach ($data as $key => $object) {
             foreach ($fields as $name => $type) {
                 if (Helpers\Validate::isNumeric($type)) {
                     $data[$key]->{$name} = 0;
                 } else {
                     $data[$key]->{$name} = null;
                 }
             }
         }
         Helpers\Data::table($this->name)->put($data);
         Helpers\Config::table($this->name)->put($config);
     }
 }
All Usage Examples Of Lazer\Classes\Helpers\Validate::isNumeric