Created
May 23, 2019 18:22
-
-
Save kschroeder/0145f952f2252b7df9df52a183719446 to your computer and use it in GitHub Desktop.
Simple script that generates the PHPDoc for methods based off of the column names in a table. To use copy the column names from your DB and execute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$returnValue = $argv[1]??'void'; | |
$output = "/**\n"; | |
$lines = explode("\n", file_get_contents('php://stdin')); | |
foreach ($lines as $line) { | |
$column = explode(' ', $line); | |
$column = array_shift($column); | |
$generatedName = explode('_', $column); | |
if (!$generatedName) continue; | |
array_walk($generatedName, function(&$value) {$value = ucfirst($value); }, null, ); | |
$generatedName = implode('', $generatedName); | |
$output .= sprintf( | |
" * @method string get%s()\n * @method %s set%s(string \$value)\n", | |
$generatedName, | |
$returnValue, | |
$generatedName | |
); | |
} | |
$output .= " */\n"; | |
echo $output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment