types() public static method

Checking that types from array matching with [boolean, integer, string, double]
public static types ( array $types ) : boolean
$types array Indexed array
return boolean
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);
     }
 }
Esempio n. 2
0
 /**
  * @covers Lazer\Classes\Helpers\Validate::types
  * @expectedException Lazer\Classes\LazerException
  */
 public function testTypesNotMatches()
 {
     $this->object->types(['integer', 'float']);
 }