|
@@ -24,7 +24,6 @@ USAGE
|
|
|
|
|
|
|
|
define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples'));
|
|
define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples'));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* transform a string to lowercase using underlines.
|
|
* transform a string to lowercase using underlines.
|
|
|
* Examples:
|
|
* Examples:
|
|
@@ -37,7 +36,8 @@ define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples'
|
|
|
* @access public
|
|
* @access public
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
|
-function getLowerCaseName($name) {
|
|
|
|
|
|
|
+function getLowerCaseName($name)
|
|
|
|
|
+{
|
|
|
return preg_replace_callback("/([A-Z])/", create_function (
|
|
return preg_replace_callback("/([A-Z])/", create_function (
|
|
|
'$match',
|
|
'$match',
|
|
|
'return "_" . strtolower($match[1]);'
|
|
'return "_" . strtolower($match[1]);'
|
|
@@ -56,14 +56,14 @@ function getLowerCaseName($name) {
|
|
|
* @access public
|
|
* @access public
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
|
-function getUpperCaseName($name) {
|
|
|
|
|
|
|
+function getUpperCaseName($name)
|
|
|
|
|
+{
|
|
|
return preg_replace_callback("/_([a-z])/", create_function (
|
|
return preg_replace_callback("/_([a-z])/", create_function (
|
|
|
'$match',
|
|
'$match',
|
|
|
'return strtoupper($match{1});'
|
|
'return strtoupper($match{1});'
|
|
|
), ucfirst($name));
|
|
), ucfirst($name));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* return the given value and echo it out appending "\n"
|
|
* return the given value and echo it out appending "\n"
|
|
|
*
|
|
*
|
|
@@ -71,8 +71,10 @@ function getUpperCaseName($name) {
|
|
|
* @access public
|
|
* @access public
|
|
|
* @return mixed
|
|
* @return mixed
|
|
|
*/
|
|
*/
|
|
|
-function out($value) {
|
|
|
|
|
|
|
+function out($value)
|
|
|
|
|
+{
|
|
|
echo $value . "\n";
|
|
echo $value . "\n";
|
|
|
|
|
+
|
|
|
return $value;
|
|
return $value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -88,7 +90,8 @@ function out($value) {
|
|
|
* @access public
|
|
* @access public
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
|
-function buildPath($directory, $filename = null, $extension = null) {
|
|
|
|
|
|
|
+function buildPath($directory, $filename = null, $extension = null)
|
|
|
|
|
+{
|
|
|
return out(EXAMPLE_PATH . '/' . $directory.
|
|
return out(EXAMPLE_PATH . '/' . $directory.
|
|
|
($extension !== null && $filename !== null ? '/' . $filename. "." . $extension : ""));
|
|
($extension !== null && $filename !== null ? '/' . $filename. "." . $extension : ""));
|
|
|
}
|
|
}
|
|
@@ -101,8 +104,9 @@ function buildPath($directory, $filename = null, $extension = null) {
|
|
|
* @access public
|
|
* @access public
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
-function createDirectory($directory) {
|
|
|
|
|
- if(!@mkdir(buildPath($directory))) {
|
|
|
|
|
|
|
+function createDirectory($directory)
|
|
|
|
|
+{
|
|
|
|
|
+ if (!@mkdir(buildPath($directory))) {
|
|
|
die("FAILED to create directory\n");
|
|
die("FAILED to create directory\n");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -118,9 +122,10 @@ function createDirectory($directory) {
|
|
|
* @access public
|
|
* @access public
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
-function createFile($directory, $filename, $extension, $content = "") {
|
|
|
|
|
|
|
+function createFile($directory, $filename, $extension, $content = "")
|
|
|
|
|
+{
|
|
|
$handle = @fopen(buildPath($directory, $filename, $extension), "w");
|
|
$handle = @fopen(buildPath($directory, $filename, $extension), "w");
|
|
|
- if($handle) {
|
|
|
|
|
|
|
+ if ($handle) {
|
|
|
fwrite($handle, $content);
|
|
fwrite($handle, $content);
|
|
|
fclose($handle);
|
|
fclose($handle);
|
|
|
} else {
|
|
} else {
|
|
@@ -128,7 +133,6 @@ function createFile($directory, $filename, $extension, $content = "") {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* routine to create the example directory and 3 files
|
|
* routine to create the example directory and 3 files
|
|
|
*
|
|
*
|
|
@@ -142,7 +146,8 @@ function createFile($directory, $filename, $extension, $content = "") {
|
|
|
* @access public
|
|
* @access public
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
-function main($example_name) {
|
|
|
|
|
|
|
+function main($example_name)
|
|
|
|
|
+{
|
|
|
$lowercase = getLowerCaseName($example_name);
|
|
$lowercase = getLowerCaseName($example_name);
|
|
|
$uppercase = getUpperCaseName($example_name);
|
|
$uppercase = getUpperCaseName($example_name);
|
|
|
createDirectory($lowercase);
|
|
createDirectory($lowercase);
|
|
@@ -160,7 +165,7 @@ CONTENT
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// check if enougth arguments are given
|
|
// check if enougth arguments are given
|
|
|
-if(count($argv) > 1) {
|
|
|
|
|
|
|
+if (count($argv) > 1) {
|
|
|
// get the name of the example
|
|
// get the name of the example
|
|
|
$example_name = $argv[1];
|
|
$example_name = $argv[1];
|
|
|
|
|
|