function main($args) { //input sanity check if (!is_array($args) || is_array($args) && !array_key_exists('name', $args)) { print_help(true); } $migration_name = $args['name']; //clear any filesystem stats cache clearstatcache(); //check to make sure our migration directory exists if (!is_dir(MIGRATION_DIR)) { die_with_error("ERROR: migration directory '" . MIGRATION_DIR . "' does not exist. Specify MIGRATION_DIR in config/config.inc.php and try again."); } //generate a complete complete $highest_version = VersionUtil::get_highest_migration(MIGRATION_DIR); $next_version = VersionUtil::to_migration_number($highest_version + 1); $klass = NamingUtil::camelcase($migration_name); $file_name = $next_version . '_' . $klass . '.php'; $full_path = realpath(MIGRATION_DIR) . '/' . $file_name; $template_str = get_template($klass); //check to make sure our destination directory is writable if (!is_writable(MIGRATION_DIR . '/')) { die_with_error("ERROR: migration directory '" . MIGRATION_DIR . "' is not writable by the current user. Check permissions and try again."); } //write it out! $file_result = file_put_contents($full_path, $template_str); if ($file_result === FALSE) { die_with_error("Error writing to migrations directory/file. Do you have sufficient privileges?"); } else { echo "\nCreated migration: {$file_name}\n\n"; } }
public function test_camelcase() { $a = "add index to users"; $this->assertEquals('AddIndexToUsers', NamingUtil::camelcase($a)); $b = "add index to Users"; $this->assertEquals('AddIndexToUsers', NamingUtil::camelcase($b)); $c = "AddIndexToUsers"; $this->assertEquals('AddIndexToUsers', NamingUtil::camelcase($c)); }