@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! ini_get ( 'short_open_tag' ) ) |
|
| 3 | +if ( ! ini_get('short_open_tag')) |
|
| 4 | 4 | { |
| 5 | - die( "please enable short_open_tag directive in php.ini\n" ); |
|
| 5 | + die("please enable short_open_tag directive in php.ini\n"); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | -if ( ! ini_get ( 'register_argc_argv' ) ) |
|
| 8 | +if ( ! ini_get('register_argc_argv')) |
|
| 9 | 9 | { |
| 10 | - die( "please enable register_argc_argv directive in php.ini\n" ); |
|
| 10 | + die("please enable register_argc_argv directive in php.ini\n"); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | if (function_exists('ini_set')) { |
| 14 | 14 | @ini_set('display_errors', 1); |
| 15 | 15 | |
| 16 | - $memoryInBytes = function ($value) { |
|
| 16 | + $memoryInBytes = function($value) { |
|
| 17 | 17 | $unit = strtolower(substr($value, -1, 1)); |
| 18 | 18 | $value = (int) $value; |
| 19 | - switch($unit) { |
|
| 19 | + switch ($unit) { |
|
| 20 | 20 | case 'g': |
| 21 | 21 | $value *= 1024; |
| 22 | 22 | // no break (cumulative multiplier) |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | unset($memoryInBytes, $memoryLimit); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -\Phar::interceptFileFuncs (); |
|
| 41 | +\Phar::interceptFileFuncs(); |
|
| 42 | 42 | |
| 43 | -set_include_path ( |
|
| 44 | - implode ( |
|
| 45 | - PATH_SEPARATOR , |
|
| 46 | - array ( |
|
| 47 | - realpath ( __DIR__ ) , |
|
| 48 | - get_include_path () , |
|
| 43 | +set_include_path( |
|
| 44 | + implode( |
|
| 45 | + PATH_SEPARATOR, |
|
| 46 | + array( |
|
| 47 | + realpath(__DIR__), |
|
| 48 | + get_include_path(), |
|
| 49 | 49 | ) |
| 50 | 50 | ) |
| 51 | 51 | ); |
@@ -56,43 +56,43 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | try |
| 58 | 58 | { |
| 59 | - $_path = realpath ( |
|
| 60 | - str_replace ( |
|
| 59 | + $_path = realpath( |
|
| 60 | + str_replace( |
|
| 61 | 61 | 'phar://' |
| 62 | - , '' , __DIR__ |
|
| 62 | + , '', __DIR__ |
|
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - $arrValid = array ( |
|
| 67 | - 'version' , |
|
| 68 | - 'help' , |
|
| 69 | - 'status' , |
|
| 70 | - 'init' , |
|
| 71 | - 'config-env:' , |
|
| 72 | - 'config-ini:' , |
|
| 73 | - 'database:' , |
|
| 74 | - 'schema:' , |
|
| 75 | - 'driver:' , |
|
| 76 | - 'framework:' , |
|
| 66 | + $arrValid = array( |
|
| 67 | + 'version', |
|
| 68 | + 'help', |
|
| 69 | + 'status', |
|
| 70 | + 'init', |
|
| 71 | + 'config-env:', |
|
| 72 | + 'config-ini:', |
|
| 73 | + 'database:', |
|
| 74 | + 'schema:', |
|
| 75 | + 'driver:', |
|
| 76 | + 'framework:', |
|
| 77 | 77 | 'path:' |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - $argv = getopt ( null, $arrValid ); |
|
| 80 | + $argv = getopt(null, $arrValid); |
|
| 81 | 81 | |
| 82 | - if ( array_key_exists ( 'init', $argv ) ) |
|
| 82 | + if (array_key_exists('init', $argv)) |
|
| 83 | 83 | { |
| 84 | - $maker = new \Classes\MakerConfigFile( $argv, $_path ); |
|
| 84 | + $maker = new \Classes\MakerConfigFile($argv, $_path); |
|
| 85 | 85 | } |
| 86 | 86 | else |
| 87 | 87 | { |
| 88 | - $maker = new \Classes\MakerFile( new \Classes\Config( $argv, $_path ) ); |
|
| 88 | + $maker = new \Classes\MakerFile(new \Classes\Config($argv, $_path)); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $maker->run (); |
|
| 91 | + $maker->run(); |
|
| 92 | 92 | |
| 93 | -} catch ( \Exception $e ) |
|
| 93 | +} catch (\Exception $e) |
|
| 94 | 94 | { |
| 95 | - die( $e->getMessage () ); |
|
| 95 | + die($e->getMessage()); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | __halt_compiler(); |
| 99 | 99 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @type string[] |
| 20 | 20 | */ |
| 21 | - public $location = array (); |
|
| 21 | + public $location = array(); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * caminho de pastas Base |
@@ -37,156 +37,156 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | private $driver; |
| 39 | 39 | |
| 40 | - public function __construct ( Config $config ) |
|
| 40 | + public function __construct(Config $config) |
|
| 41 | 41 | { |
| 42 | - $this->config = $config->getAdapterConfig (); |
|
| 43 | - $this->driver = $config->getAdapterDriver (); |
|
| 44 | - $this->parseLocation ( $config->_basePath ); |
|
| 42 | + $this->config = $config->getAdapterConfig(); |
|
| 43 | + $this->driver = $config->getAdapterDriver(); |
|
| 44 | + $this->parseLocation($config->_basePath); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Analisa os caminhos das pastas base |
| 49 | 49 | */ |
| 50 | - public function parseLocation ( $basePath ) |
|
| 50 | + public function parseLocation($basePath) |
|
| 51 | 51 | { |
| 52 | 52 | |
| 53 | - $arrBase = array ( |
|
| 54 | - $basePath , |
|
| 53 | + $arrBase = array( |
|
| 54 | + $basePath, |
|
| 55 | 55 | $this->config->path |
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | - $this->baseLocation = implode ( DIRECTORY_SEPARATOR , array_filter ( $arrBase ) ); |
|
| 58 | + $this->baseLocation = implode(DIRECTORY_SEPARATOR, array_filter($arrBase)); |
|
| 59 | 59 | |
| 60 | 60 | # pasta com nome do driver do banco |
| 61 | 61 | $driverBase = ''; |
| 62 | - if ( $this->config->{"folder-database"} ) |
|
| 62 | + if ($this->config->{"folder-database"} ) |
|
| 63 | 63 | { |
| 64 | - $classDriver = explode ( '\\' , get_class ( $this->driver ) ); |
|
| 65 | - $driverBase = end ( $classDriver ); |
|
| 64 | + $classDriver = explode('\\', get_class($this->driver)); |
|
| 65 | + $driverBase = end($classDriver); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if ( $this->config->hasSchemas () ) |
|
| 68 | + if ($this->config->hasSchemas()) |
|
| 69 | 69 | { |
| 70 | 70 | |
| 71 | - $schemas = $this->config->getSchemas (); |
|
| 72 | - foreach ( $schemas as $schema ) |
|
| 71 | + $schemas = $this->config->getSchemas(); |
|
| 72 | + foreach ($schemas as $schema) |
|
| 73 | 73 | { |
| 74 | - $arrUrl = array ( |
|
| 75 | - $this->baseLocation , |
|
| 76 | - $driverBase , |
|
| 77 | - $this->getClassName ( $schema ) |
|
| 74 | + $arrUrl = array( |
|
| 75 | + $this->baseLocation, |
|
| 76 | + $driverBase, |
|
| 77 | + $this->getClassName($schema) |
|
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - $this->location[ $schema ] = implode ( DIRECTORY_SEPARATOR , array_filter ( $arrUrl ) ); |
|
| 81 | - unset( $arrUrl ); |
|
| 80 | + $this->location[$schema] = implode(DIRECTORY_SEPARATOR, array_filter($arrUrl)); |
|
| 81 | + unset($arrUrl); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | } else |
| 86 | 86 | { |
| 87 | - $baseLocation = implode ( |
|
| 88 | - DIRECTORY_SEPARATOR , array_filter ( array ( |
|
| 89 | - $this->baseLocation , |
|
| 90 | - $driverBase , |
|
| 91 | - $this->getClassName ( $this->getConfig()->getDatabase () ) |
|
| 87 | + $baseLocation = implode( |
|
| 88 | + DIRECTORY_SEPARATOR, array_filter(array( |
|
| 89 | + $this->baseLocation, |
|
| 90 | + $driverBase, |
|
| 91 | + $this->getClassName($this->getConfig()->getDatabase()) |
|
| 92 | 92 | ) |
| 93 | 93 | ) |
| 94 | 94 | ); |
| 95 | - $this->location = array ( $baseLocation ); |
|
| 95 | + $this->location = array($baseLocation); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @return AdapterConfig\AbstractAdapter |
| 101 | 101 | */ |
| 102 | - public function getConfig () |
|
| 102 | + public function getConfig() |
|
| 103 | 103 | { |
| 104 | 104 | return $this->config; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /* Get current time */ |
| 108 | - public function startTime () |
|
| 108 | + public function startTime() |
|
| 109 | 109 | { |
| 110 | 110 | echo "Starting..\n"; |
| 111 | - $this->startTime = microtime ( true ); |
|
| 111 | + $this->startTime = microtime(true); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - private function getRunTime () |
|
| 114 | + private function getRunTime() |
|
| 115 | 115 | { |
| 116 | - return round ( ( microtime ( true ) - $this->startTime ) , 3 ); |
|
| 116 | + return round((microtime(true) - $this->startTime), 3); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Executa o Make, criando arquivos e Diretorios |
| 121 | 121 | */ |
| 122 | - public function run () |
|
| 122 | + public function run() |
|
| 123 | 123 | { |
| 124 | - $this->startTime (); |
|
| 125 | - $this->driver->runDatabase (); |
|
| 126 | - $max = $this->driver->getTotalTables () * count ( $this->factoryMakerFile () ); |
|
| 124 | + $this->startTime(); |
|
| 125 | + $this->driver->runDatabase(); |
|
| 126 | + $max = $this->driver->getTotalTables() * count($this->factoryMakerFile()); |
|
| 127 | 127 | $cur = 0; |
| 128 | 128 | |
| 129 | 129 | |
| 130 | - foreach ( $this->location as $schema => $location ) |
|
| 130 | + foreach ($this->location as $schema => $location) |
|
| 131 | 131 | { |
| 132 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) |
|
| 132 | + foreach ($this->factoryMakerFile() as $objMakeFile) |
|
| 133 | 133 | { |
| 134 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
| 135 | - self::makeDir ( $path ); |
|
| 134 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
| 135 | + self::makeDir($path); |
|
| 136 | 136 | |
| 137 | - if ( $objMakeFile->getParentFileTpl () != '' ) |
|
| 137 | + if ($objMakeFile->getParentFileTpl() != '') |
|
| 138 | 138 | { |
| 139 | 139 | $fileAbstract = $this->baseLocation |
| 140 | 140 | . DIRECTORY_SEPARATOR |
| 141 | - . $objMakeFile->getParentClass () . '.php'; |
|
| 141 | + . $objMakeFile->getParentClass() . '.php'; |
|
| 142 | 142 | |
| 143 | - $tplAbstract = $this->getParsedTplContents ( $objMakeFile->getParentFileTpl () ); |
|
| 144 | - self::makeSourcer ( $fileAbstract , $tplAbstract, $objMakeFile->isOverwrite() ); |
|
| 145 | - unset( $fileAbstract , $tplAbstract ); |
|
| 143 | + $tplAbstract = $this->getParsedTplContents($objMakeFile->getParentFileTpl()); |
|
| 144 | + self::makeSourcer($fileAbstract, $tplAbstract, $objMakeFile->isOverwrite()); |
|
| 145 | + unset($fileAbstract, $tplAbstract); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | foreach ( |
| 149 | - $this->driver->getTables ( $schema ) as $key => $objTables |
|
| 149 | + $this->driver->getTables($schema) as $key => $objTables |
|
| 150 | 150 | ) |
| 151 | 151 | { |
| 152 | - $total = ceil ($cur / $max) * 100; |
|
| 153 | - printf ( "\r Creating: %6.2f%%" , $total ); |
|
| 154 | - $cur ++; |
|
| 152 | + $total = ceil($cur / $max) * 100; |
|
| 153 | + printf("\r Creating: %6.2f%%", $total); |
|
| 154 | + $cur++; |
|
| 155 | 155 | |
| 156 | 156 | $file = $path |
| 157 | 157 | . DIRECTORY_SEPARATOR |
| 158 | - . self::getClassName ( $objTables->getName () ) |
|
| 158 | + . self::getClassName($objTables->getName()) |
|
| 159 | 159 | . '.php'; |
| 160 | 160 | |
| 161 | 161 | |
| 162 | - $tpl = $this->getParsedTplContents ( |
|
| 163 | - $objMakeFile->getFileTpl () , |
|
| 164 | - $objMakeFile->parseRelation ( $this , $objTables ) |
|
| 165 | - , $objTables , $objMakeFile |
|
| 162 | + $tpl = $this->getParsedTplContents( |
|
| 163 | + $objMakeFile->getFileTpl(), |
|
| 164 | + $objMakeFile->parseRelation($this, $objTables) |
|
| 165 | + , $objTables, $objMakeFile |
|
| 166 | 166 | |
| 167 | 167 | ); |
| 168 | - self::makeSourcer ( $file , $tpl, $objMakeFile->isOverwrite() ); |
|
| 168 | + self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite()); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $this->reportProcess ( $cur ); |
|
| 174 | + $this->reportProcess($cur); |
|
| 175 | 175 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - private function reportProcess ( $countFiles ) |
|
| 178 | + private function reportProcess($countFiles) |
|
| 179 | 179 | { |
| 180 | - if ( $this->config->isStatusEnabled () ) |
|
| 180 | + if ($this->config->isStatusEnabled()) |
|
| 181 | 181 | { |
| 182 | - $databases = count ( $this->location ); |
|
| 183 | - $countDir = $this->countDiretory (); |
|
| 184 | - $totalTable = $this->driver->getTotalTables (); |
|
| 182 | + $databases = count($this->location); |
|
| 183 | + $countDir = $this->countDiretory(); |
|
| 184 | + $totalTable = $this->driver->getTotalTables(); |
|
| 185 | 185 | echo "\n------"; |
| 186 | - printf ( "\n\r-Files generated:%s" , $countFiles ); |
|
| 187 | - printf ( "\n\r-Diretory generated:%s" , $databases * $countDir ); |
|
| 188 | - printf ( "\n\r-Scanned tables:%s" , $totalTable ); |
|
| 189 | - printf ( "\n\r-Execution time: %ssec" , $this->getRunTime () ); |
|
| 186 | + printf("\n\r-Files generated:%s", $countFiles); |
|
| 187 | + printf("\n\r-Diretory generated:%s", $databases * $countDir); |
|
| 188 | + printf("\n\r-Scanned tables:%s", $totalTable); |
|
| 189 | + printf("\n\r-Execution time: %ssec", $this->getRunTime()); |
|
| 190 | 190 | echo "\n------"; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @return AbstractAdapter[] |
| 198 | 198 | */ |
| 199 | - public function factoryMakerFile () |
|
| 199 | + public function factoryMakerFile() |
|
| 200 | 200 | { |
| 201 | - return $this->config->getMakeFileInstances (); |
|
| 201 | + return $this->config->getMakeFileInstances(); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return int |
| 208 | 208 | */ |
| 209 | - public function countDiretory () |
|
| 209 | + public function countDiretory() |
|
| 210 | 210 | { |
| 211 | 211 | $dir = 0; |
| 212 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) |
|
| 212 | + foreach ($this->factoryMakerFile() as $abstractAdapter) |
|
| 213 | 213 | { |
| 214 | - if ( $abstractAdapter->hasDiretory () ) |
|
| 214 | + if ($abstractAdapter->hasDiretory()) |
|
| 215 | 215 | { |
| 216 | - $dir ++; |
|
| 216 | + $dir++; |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -228,23 +228,23 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return String |
| 230 | 230 | */ |
| 231 | - protected function getParsedTplContents ( $tplFile , $vars = array () , \Classes\Db\DbTable $objTables = null , $objMakeFile = null ) |
|
| 231 | + protected function getParsedTplContents($tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, $objMakeFile = null) |
|
| 232 | 232 | { |
| 233 | 233 | |
| 234 | - $arrUrl = array ( |
|
| 235 | - __DIR__ , |
|
| 236 | - 'templates' , |
|
| 237 | - $this->config->framework , |
|
| 234 | + $arrUrl = array( |
|
| 235 | + __DIR__, |
|
| 236 | + 'templates', |
|
| 237 | + $this->config->framework, |
|
| 238 | 238 | $tplFile |
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | - $filePath = implode ( DIRECTORY_SEPARATOR , filter_var_array ( $arrUrl ) ); |
|
| 241 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
| 242 | 242 | |
| 243 | - extract ( $vars ); |
|
| 244 | - ob_start (); |
|
| 243 | + extract($vars); |
|
| 244 | + ob_start(); |
|
| 245 | 245 | require $filePath; |
| 246 | - $data = ob_get_contents (); |
|
| 247 | - ob_end_clean (); |
|
| 246 | + $data = ob_get_contents(); |
|
| 247 | + ob_end_clean(); |
|
| 248 | 248 | |
| 249 | 249 | return $data; |
| 250 | 250 | } |
@@ -24,21 +24,21 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | private $msg = "\033[0mPlease enter the value for %index% \033[1;33m[%config%]:\033[0m "; |
| 26 | 26 | |
| 27 | - private $configs = array ( |
|
| 28 | - 'config-env' => 'config' , |
|
| 29 | - 'framework' => 'none' , |
|
| 30 | - 'driver' => 'pgsql' , |
|
| 31 | - 'environment' => 'dev' , |
|
| 32 | - 'host' => 'localhost' , |
|
| 33 | - 'database' => null , |
|
| 34 | - 'schema' => null , |
|
| 35 | - 'username' => null , |
|
| 27 | + private $configs = array( |
|
| 28 | + 'config-env' => 'config', |
|
| 29 | + 'framework' => 'none', |
|
| 30 | + 'driver' => 'pgsql', |
|
| 31 | + 'environment' => 'dev', |
|
| 32 | + 'host' => 'localhost', |
|
| 33 | + 'database' => null, |
|
| 34 | + 'schema' => null, |
|
| 35 | + 'username' => null, |
|
| 36 | 36 | 'password' => null |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - public function __construct ( $argv , $basePath ) |
|
| 39 | + public function __construct($argv, $basePath) |
|
| 40 | 40 | { |
| 41 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
| 41 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -50,32 +50,32 @@ discard block |
||
| 50 | 50 | * @return array |
| 51 | 51 | * @throws \Exception |
| 52 | 52 | */ |
| 53 | - private function parseConfig ( $basePath , $argv ) |
|
| 53 | + private function parseConfig($basePath, $argv) |
|
| 54 | 54 | { |
| 55 | - $this->baseLocation = dirname ( $basePath ); |
|
| 55 | + $this->baseLocation = dirname($basePath); |
|
| 56 | 56 | |
| 57 | - $arrayIO = array_diff_key ( $this->configs , $argv ); |
|
| 58 | - foreach ( $arrayIO as $index => $config ) |
|
| 57 | + $arrayIO = array_diff_key($this->configs, $argv); |
|
| 58 | + foreach ($arrayIO as $index => $config) |
|
| 59 | 59 | { |
| 60 | - $attribs = array ( "%index%" => $index , "%config%" => $config ); |
|
| 61 | - echo strtr ( $this->msg , $attribs ); |
|
| 62 | - $line = trim ( fgets ( STDIN ) ); |
|
| 63 | - if ( ! empty( $line ) ) |
|
| 60 | + $attribs = array("%index%" => $index, "%config%" => $config); |
|
| 61 | + echo strtr($this->msg, $attribs); |
|
| 62 | + $line = trim(fgets(STDIN)); |
|
| 63 | + if ( ! empty($line)) |
|
| 64 | 64 | { |
| 65 | - $this->configs[ $index ] = strtolower ( $line ); |
|
| 65 | + $this->configs[$index] = strtolower($line); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | - $this->configs ['version'] = Config::$version; |
|
| 69 | - return $argv + array_filter ( $this->configs ); |
|
| 68 | + $this->configs ['version'] = Config::$version; |
|
| 69 | + return $argv + array_filter($this->configs); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function run () |
|
| 72 | + public function run() |
|
| 73 | 73 | { |
| 74 | 74 | $path = $this->baseLocation . DIRECTORY_SEPARATOR . "configs"; |
| 75 | - self::makeDir ( $path ); |
|
| 76 | - self::makeSourcer ( |
|
| 77 | - $path . DIRECTORY_SEPARATOR . $this->argv[ 'config-env' ] . '.ini' , |
|
| 78 | - $this->getParsedTplContents ( $this->template , $this->argv ) |
|
| 75 | + self::makeDir($path); |
|
| 76 | + self::makeSourcer( |
|
| 77 | + $path . DIRECTORY_SEPARATOR . $this->argv['config-env'] . '.ini', |
|
| 78 | + $this->getParsedTplContents($this->template, $this->argv) |
|
| 79 | 79 | ); |
| 80 | 80 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
| 81 | 81 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return array[] |
| 80 | 80 | */ |
| 81 | - public function getListColumns () |
|
| 81 | + public function getListColumns() |
|
| 82 | 82 | { |
| 83 | 83 | // TODO: Implement getListColumns() method. |
| 84 | 84 | } |
@@ -88,17 +88,17 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return int |
| 90 | 90 | */ |
| 91 | - public function getTotalTables () |
|
| 91 | + public function getTotalTables() |
|
| 92 | 92 | { |
| 93 | 93 | // TODO: Implement totalTables() method. |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function getSequence ( $table , $column ) |
|
| 96 | + public function getSequence($table, $column) |
|
| 97 | 97 | { |
| 98 | 98 | // TODO: Implement getSequence() method. |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function getListConstrant () |
|
| 101 | + public function getListConstrant() |
|
| 102 | 102 | { |
| 103 | 103 | // TODO: Implement getListConstrant() method. |
| 104 | 104 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | protected $parentFileTpl = ""; |
| 18 | 18 | protected $fileTpl = "model.php"; |
| 19 | 19 | |
| 20 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
| 20 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 21 | 21 | { |
| 22 | 22 | return array(); |
| 23 | 23 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | protected $fileTpl = "entity.php"; |
| 23 | 23 | protected $overwrite = true; |
| 24 | 24 | |
| 25 | - protected $validFunc = array (); |
|
| 25 | + protected $validFunc = array(); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param \Classes\MakerFile $makerFile |
@@ -30,68 +30,68 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return array |
| 32 | 32 | */ |
| 33 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
| 33 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 34 | 34 | { |
| 35 | 35 | |
| 36 | - $parents = array (); |
|
| 37 | - $depends = array (); |
|
| 38 | - foreach ( $dbTable->getForeingkeys () as $fks ) |
|
| 36 | + $parents = array(); |
|
| 37 | + $depends = array(); |
|
| 38 | + foreach ($dbTable->getForeingkeys() as $fks) |
|
| 39 | 39 | { |
| 40 | - $constrant = $fks->getFks (); |
|
| 40 | + $constrant = $fks->getFks(); |
|
| 41 | 41 | $name = |
| 42 | 42 | 'Parent' |
| 43 | 43 | . ZendFrameworkOne::SEPARETOR |
| 44 | - . AbstractMaker::getClassName ( $constrant->getTable () ) |
|
| 44 | + . AbstractMaker::getClassName($constrant->getTable()) |
|
| 45 | 45 | . ZendFrameworkOne::SEPARETOR |
| 46 | 46 | . 'By' |
| 47 | 47 | . ZendFrameworkOne::SEPARETOR |
| 48 | - . $constrant->getColumn (); |
|
| 48 | + . $constrant->getColumn(); |
|
| 49 | 49 | |
| 50 | - $parents[] = array ( |
|
| 51 | - 'class' => $makerFile->getConfig () |
|
| 52 | - ->createClassNamespace ( $constrant ) |
|
| 50 | + $parents[] = array( |
|
| 51 | + 'class' => $makerFile->getConfig() |
|
| 52 | + ->createClassNamespace($constrant) |
|
| 53 | 53 | . ZendFrameworkOne::SEPARETOR |
| 54 | - . AbstractMaker::getClassName ( $constrant->getTable () ), |
|
| 55 | - 'function' => AbstractMaker::getClassName ( $name ), |
|
| 56 | - 'table' => $constrant->getTable (), |
|
| 57 | - 'column' => $fks->getName (), |
|
| 58 | - 'name' => $constrant->getNameConstrant (), |
|
| 54 | + . AbstractMaker::getClassName($constrant->getTable()), |
|
| 55 | + 'function' => AbstractMaker::getClassName($name), |
|
| 56 | + 'table' => $constrant->getTable(), |
|
| 57 | + 'column' => $fks->getName(), |
|
| 58 | + 'name' => $constrant->getNameConstrant(), |
|
| 59 | 59 | ); |
| 60 | - unset( $name ); |
|
| 60 | + unset($name); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
| 63 | + foreach ($dbTable->getDependences() as $objColumn) |
|
| 64 | 64 | { |
| 65 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
| 65 | + foreach ($objColumn->getDependences() as $dependence) |
|
| 66 | 66 | { |
| 67 | 67 | $name = |
| 68 | 68 | 'Depend' |
| 69 | 69 | . ZendFrameworkOne::SEPARETOR |
| 70 | - . AbstractMaker::getClassName ( $dependence->getTable () ) |
|
| 70 | + . AbstractMaker::getClassName($dependence->getTable()) |
|
| 71 | 71 | . ZendFrameworkOne::SEPARETOR |
| 72 | 72 | . 'By' |
| 73 | 73 | . ZendFrameworkOne::SEPARETOR |
| 74 | - . $dependence->getColumn (); |
|
| 74 | + . $dependence->getColumn(); |
|
| 75 | 75 | |
| 76 | - if ( !key_exists ( $name, $this->validFunc ) ) |
|
| 76 | + if ( ! key_exists($name, $this->validFunc)) |
|
| 77 | 77 | { |
| 78 | - $this->validFunc[ $name ] = true; |
|
| 79 | - $depends[] = array ( |
|
| 80 | - 'class' => $makerFile->getConfig () |
|
| 81 | - ->createClassNamespace ( $dependence ) |
|
| 78 | + $this->validFunc[$name] = true; |
|
| 79 | + $depends[] = array( |
|
| 80 | + 'class' => $makerFile->getConfig() |
|
| 81 | + ->createClassNamespace($dependence) |
|
| 82 | 82 | . ZendFrameworkOne::SEPARETOR |
| 83 | - . AbstractMaker::getClassName ( $dependence->getTable () ), |
|
| 84 | - 'function' => AbstractMaker::getClassName ( $name ), |
|
| 85 | - 'table' => $dependence->getTable (), |
|
| 86 | - 'column' => $dependence->getColumn (), |
|
| 87 | - 'name' => $dependence->getNameConstrant () |
|
| 83 | + . AbstractMaker::getClassName($dependence->getTable()), |
|
| 84 | + 'function' => AbstractMaker::getClassName($name), |
|
| 85 | + 'table' => $dependence->getTable(), |
|
| 86 | + 'column' => $dependence->getColumn(), |
|
| 87 | + 'name' => $dependence->getNameConstrant() |
|
| 88 | 88 | ); |
| 89 | 89 | } |
| 90 | - unset( $name ); |
|
| 90 | + unset($name); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return array ( |
|
| 94 | + return array( |
|
| 95 | 95 | 'parents' => $parents, |
| 96 | 96 | 'depends' => $depends |
| 97 | 97 | ); |
@@ -28,60 +28,60 @@ |
||
| 28 | 28 | * |
| 29 | 29 | * @return string[] |
| 30 | 30 | */ |
| 31 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
| 31 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 32 | 32 | { |
| 33 | 33 | $referenceMap = ''; |
| 34 | - $references = array (); |
|
| 34 | + $references = array(); |
|
| 35 | 35 | $dependentTables = ''; |
| 36 | - $dependents = array (); |
|
| 37 | - foreach ( $dbTable->getForeingkeys () as $fk ) |
|
| 36 | + $dependents = array(); |
|
| 37 | + foreach ($dbTable->getForeingkeys() as $fk) |
|
| 38 | 38 | { |
| 39 | - $constrant = $fk->getFks (); |
|
| 40 | - $references[] = sprintf ( |
|
| 39 | + $constrant = $fk->getFks(); |
|
| 40 | + $references[] = sprintf( |
|
| 41 | 41 | " |
| 42 | 42 | '%s' => array ( |
| 43 | 43 | 'columns' => '%s' , |
| 44 | 44 | 'refTableClass' => '%s', |
| 45 | 45 | 'refColumns' =>'%s' |
| 46 | 46 | )", |
| 47 | - AbstractMaker::getClassName ( $constrant->getNameConstrant () ), |
|
| 48 | - $fk->getName (), |
|
| 49 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ) |
|
| 47 | + AbstractMaker::getClassName($constrant->getNameConstrant()), |
|
| 48 | + $fk->getName(), |
|
| 49 | + $makerFile->getConfig()->createClassNamespace($constrant) |
|
| 50 | 50 | . ZendFrameworkOne::SEPARETOR |
| 51 | 51 | . 'DbTable' |
| 52 | 52 | . ZendFrameworkOne::SEPARETOR |
| 53 | - . AbstractMaker::getClassName ( $constrant->getTable () ), |
|
| 54 | - $constrant->getColumn () |
|
| 53 | + . AbstractMaker::getClassName($constrant->getTable()), |
|
| 54 | + $constrant->getColumn() |
|
| 55 | 55 | |
| 56 | 56 | ); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if ( sizeof ( $references ) > 0 ) |
|
| 59 | + if (sizeof($references) > 0) |
|
| 60 | 60 | { |
| 61 | 61 | $referenceMap = "protected \$_referenceMap = array(" . |
| 62 | - join ( ',', $references ) . "\n );"; |
|
| 62 | + join(',', $references) . "\n );"; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
| 65 | + foreach ($dbTable->getDependences() as $objColumn) |
|
| 66 | 66 | { |
| 67 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
| 67 | + foreach ($objColumn->getDependences() as $dependence) |
|
| 68 | 68 | { |
| 69 | - $dependents[] = $makerFile->getConfig ()->createClassNamespace ( $dependence ) |
|
| 69 | + $dependents[] = $makerFile->getConfig()->createClassNamespace($dependence) |
|
| 70 | 70 | . ZendFrameworkOne::SEPARETOR |
| 71 | 71 | . 'DbTable' |
| 72 | 72 | . ZendFrameworkOne::SEPARETOR |
| 73 | - . AbstractMaker::getClassName ( $dependence->getTable () ); |
|
| 73 | + . AbstractMaker::getClassName($dependence->getTable()); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( sizeof ( $dependents ) > 0 ) |
|
| 77 | + if (sizeof($dependents) > 0) |
|
| 78 | 78 | { |
| 79 | 79 | $dependentTables = "protected \$_dependentTables = array(\n '" . |
| 80 | - join ( "',\n '", $dependents ) . "'\n );"; |
|
| 80 | + join("',\n '", $dependents) . "'\n );"; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
| 84 | - return array ( |
|
| 84 | + return array( |
|
| 85 | 85 | 'referenceMap' => $referenceMap, |
| 86 | 86 | 'dependentTables' => $dependentTables |
| 87 | 87 | ); |
@@ -11,29 +11,29 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @type AbstractAdapter[] |
| 13 | 13 | */ |
| 14 | - private static $_instance = array (); |
|
| 14 | + private static $_instance = array(); |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | - private function __construct () |
|
| 19 | + private function __construct() |
|
| 20 | 20 | { |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @return \Classes\AdapterMakerFile\AbstractAdapter |
| 25 | 25 | */ |
| 26 | - public static function getInstance () |
|
| 26 | + public static function getInstance() |
|
| 27 | 27 | { |
| 28 | - $class = get_called_class (); |
|
| 29 | - $arr = explode ( '\\', $class ); |
|
| 30 | - $classEnd = end ( $arr ); |
|
| 31 | - if ( !isset( self::$_instance[ $classEnd ] ) ) |
|
| 28 | + $class = get_called_class(); |
|
| 29 | + $arr = explode('\\', $class); |
|
| 30 | + $classEnd = end($arr); |
|
| 31 | + if ( ! isset(self::$_instance[$classEnd])) |
|
| 32 | 32 | { |
| 33 | - self::$_instance[ $classEnd ] = new $class(); |
|
| 33 | + self::$_instance[$classEnd] = new $class(); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - return self::$_instance[ $classEnd ]; |
|
| 36 | + return self::$_instance[$classEnd]; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return string[] |
| 44 | 44 | */ |
| 45 | - public abstract function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ); |
|
| 45 | + public abstract function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @type string |
@@ -74,15 +74,15 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - public function hasDiretory () |
|
| 77 | + public function hasDiretory() |
|
| 78 | 78 | { |
| 79 | - return !empty( $this->pastName ); |
|
| 79 | + return ! empty($this->pastName); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | - public function getParentClass () |
|
| 85 | + public function getParentClass() |
|
| 86 | 86 | { |
| 87 | 87 | return $this->parentClass; |
| 88 | 88 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * @return string |
| 93 | 93 | */ |
| 94 | - public function getFileTpl () |
|
| 94 | + public function getFileTpl() |
|
| 95 | 95 | { |
| 96 | 96 | return $this->fileTpl; |
| 97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * @return string |
| 101 | 101 | */ |
| 102 | - public function getParentFileTpl () |
|
| 102 | + public function getParentFileTpl() |
|
| 103 | 103 | { |
| 104 | 104 | return $this->parentFileTpl; |
| 105 | 105 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | - public function getPastName () |
|
| 110 | + public function getPastName() |
|
| 111 | 111 | { |
| 112 | 112 | return $this->pastName; |
| 113 | 113 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | /** |
| 116 | 116 | * @return bool |
| 117 | 117 | */ |
| 118 | - public function isOverwrite () |
|
| 118 | + public function isOverwrite() |
|
| 119 | 119 | { |
| 120 | 120 | return $this->overwrite; |
| 121 | 121 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | const SEPARETOR = "_"; |
| 19 | 19 | |
| 20 | - protected function init () |
|
| 20 | + protected function init() |
|
| 21 | 21 | { |
| 22 | 22 | } |
| 23 | 23 | |
@@ -26,28 +26,28 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return array |
| 28 | 28 | */ |
| 29 | - protected function getParams () |
|
| 29 | + protected function getParams() |
|
| 30 | 30 | { |
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - protected function parseFrameworkConfig () |
|
| 34 | + protected function parseFrameworkConfig() |
|
| 35 | 35 | { |
| 36 | 36 | // TODO: Implement parseFrameworkConfig() method. |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function createClassNamespace ( $table ) |
|
| 39 | + public function createClassNamespace($table) |
|
| 40 | 40 | { |
| 41 | - $arrNames = array ( |
|
| 42 | - $this->arrConfig[ 'namespace' ], |
|
| 41 | + $arrNames = array( |
|
| 42 | + $this->arrConfig['namespace'], |
|
| 43 | 43 | 'Model' |
| 44 | 44 | ); |
| 45 | - if ( $table->hasSchema () ) |
|
| 45 | + if ($table->hasSchema()) |
|
| 46 | 46 | { |
| 47 | - $arrNames[] = ucfirst ( $table->getSchema () ); |
|
| 47 | + $arrNames[] = ucfirst($table->getSchema()); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return implode ( '_', array_filter ( $arrNames ) ); |
|
| 50 | + return implode('_', array_filter($arrNames)); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return AbstractAdapter[] |
| 57 | 57 | */ |
| 58 | - public function getMakeFileInstances () |
|
| 58 | + public function getMakeFileInstances() |
|
| 59 | 59 | { |
| 60 | - return array ( |
|
| 60 | + return array( |
|
| 61 | 61 | ); |
| 62 | 62 | } |
| 63 | 63 | |