public function testGetCustomVariableIndexFromFieldName() { $this->assertSame(0, Model::getCustomVariableIndexFromFieldName('custom_var_k0')); $this->assertSame(0, Model::getCustomVariableIndexFromFieldName('custom_var_v0')); $this->assertSame(5, Model::getCustomVariableIndexFromFieldName('custom_var_k5')); $this->assertSame(5, Model::getCustomVariableIndexFromFieldName('custom_var_v5')); $this->assertSame(938, Model::getCustomVariableIndexFromFieldName('custom_var_k938')); $this->assertSame(938, Model::getCustomVariableIndexFromFieldName('custom_var_v938')); $this->assertSame(null, Model::getCustomVariableIndexFromFieldName('otherfield')); }
public function getCustomVarIndexes() { $columns = $this->getCustomVarColumnNames(); if (empty($columns)) { return array(); } $indexes = array_map(function ($column) { return Model::getCustomVariableIndexFromFieldName($column); }, $columns); return array_values(array_unique($indexes)); }