// Connection password define('DB_PASS', 'password'); // Database name for "Information Schema", if there's a name change, in the future define('INFO_SCHEMA', 'information_schema'); // Name of the field identifying a group define('SEARCHED_FIELD', 'gid'); // CSV File containing the groups oldname / newname pairs define('CSV_FILE', './test_csv.csv'); // log file define('LOGFILE', '/tmp/renameGroups.log'); /******* END CONF *********************/ require_once 'vendor/autoload.php'; use League\Csv\Reader; /******* MAIN *********************/ $climate = new League\CLImate\CLImate(); $climate->green()->out('RenameGroups launched'); $logger = new Logger(LOGFILE); $gr = new GroupRenamer(); // comment if you don't want complete log (only exceptions will be logged) $gr->setLogger($logger); $gr->setCli($climate); try { $gr->run(); } catch (Exception $e) { $climate->red()->out('ERROR ! ' . $e->getMessage()); $logger->put($e->getMessage()); } $climate->green()->out('END'); /******* END MAIN *********************/ class GroupRenamer {
<?php require_once 'vendor/autoload.php'; use Exercise\Helpers\StringHelper; $climate = new League\CLImate\CLImate(); $climate->description("This is php exercise test script"); $climate->arguments->add(['string' => ['prefix' => 's', 'description' => 'Input string for processing', 'required' => true]]); if (!$climate->arguments->defined("string")) { $climate->usage(); exit; } $climate->arguments->parse(); $inputString = $climate->arguments->get("string"); $climate->clear(); $climate->red('Hello. This is php exercise script.'); $climate->green()->inline("Input string: ")->white($inputString); $stringHelper = new StringHelper(); $climate->green()->inline("Out string: ")->white($stringHelper->revertAndExcludeVowels($inputString));