public function testBuild() { $component = new Reference('tbl', array('id')); $this->assertEquals('`tbl` (`id`)', Reference::build($component)); }
/** * @param FieldDefinition|FieldDefinition[] $component The component to be built. * * @return string */ public static function build($component) { if (is_array($component)) { $ret = array(); foreach ($component as $c) { $ret[] = static::build($c); } return "(\n" . implode(",\n", $ret) . "\n)"; } else { $tmp = ''; if ($component->isConstraint) { $tmp .= 'CONSTRAINT '; } if (!empty($component->name)) { $tmp .= Context::escape($component->name) . ' '; } if (!empty($component->type)) { $tmp .= DataType::build($component->type) . ' '; } if (!empty($component->key)) { $tmp .= Key::build($component->key) . ' '; } if (!empty($component->references)) { $tmp .= 'REFERENCES ' . Reference::build($component->references) . ' '; } $tmp .= OptionsArray::build($component->options); return trim($tmp); } }