@@ -3,21 +3,21 @@ |
||
| 3 | 3 | /** |
| 4 | 4 | * Application Model Peer |
| 5 | 5 | * |
| 6 | - * <?=$this->config->last_modify."\n"?> |
|
| 6 | + * <?=$this->config->last_modify . "\n"?> |
|
| 7 | 7 | * |
| 8 | 8 | * Tabela definida por 'tablename' |
| 9 | 9 | * |
| 10 | 10 | * @package <?=$objTables->getNamespace()?><?="\n"?> |
| 11 | 11 | * @subpackage Peer |
| 12 | - * @author <?=$this->config->author."\n"?> |
|
| 12 | + * @author <?=$this->config->author . "\n"?> |
|
| 13 | 13 | * |
| 14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
| 15 | - * @license <?=$this->config->license."\n"?> |
|
| 16 | - * @link <?=$this->config->link."\n"?> |
|
| 17 | - * @version <?=$this->config->version."\n"?> |
|
| 14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
| 15 | + * @license <?=$this->config->license . "\n"?> |
|
| 16 | + * @link <?=$this->config->link . "\n"?> |
|
| 17 | + * @version <?=$this->config->version . "\n"?> |
|
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -class <?=$objTables->getNamespace()?>_Peer_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$objTables->getNamespace()?$objTables->getNamespace()."_":''?>DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ) . "\n"?> |
|
| 20 | +class <?=$objTables->getNamespace()?>_Peer_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$objTables->getNamespace() ? $objTables->getNamespace() . "_" : ''?>DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n"?> |
|
| 21 | 21 | { |
| 22 | 22 | /* @TODO Codifique aqui */ |
| 23 | 23 | } |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
| 21 | 21 | { |
| 22 | - return array(); |
|
| 22 | + return array(); |
|
| 23 | 23 | } |
| 24 | 24 | } |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | * @var void |
| 14 | 14 | */ |
| 15 | 15 | protected $fileTpl = "model.php"; |
| 16 | - protected $fileFixedData = array ( |
|
| 17 | - 'exception' => array ( |
|
| 18 | - 'tpl' => "model_exception.php" , |
|
| 16 | + protected $fileFixedData = array( |
|
| 17 | + 'exception' => array( |
|
| 18 | + 'tpl' => "model_exception.php", |
|
| 19 | 19 | 'name' => "Exception" |
| 20 | 20 | ) |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
| 23 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 24 | 24 | { |
| 25 | 25 | return array(); |
| 26 | 26 | } |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
| 82 | 82 | |
| 83 | 83 | if(!in_array($class,$dependents)){ |
| 84 | - $dependents[] = $class; |
|
| 84 | + $dependents[] = $class; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public $pastName = 'DbTable'; |
| 17 | 17 | protected $fileTpl = "dbtable.php"; |
| 18 | - protected $fileFixedData = array ( |
|
| 19 | - 'parentclass' => array ( |
|
| 20 | - 'name' => "TableAbstract" , |
|
| 18 | + protected $fileFixedData = array( |
|
| 19 | + 'parentclass' => array( |
|
| 20 | + 'name' => "TableAbstract", |
|
| 21 | 21 | 'tpl' => "dbtable_abstract.php" |
| 22 | 22 | ) |
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | - protected $overwrite = true; |
|
| 25 | + protected $overwrite = true; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param \Classes\MakerFile $makerFile |
@@ -30,70 +30,70 @@ 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 | $referenceMap = ''; |
| 36 | - $references = array (); |
|
| 36 | + $references = array(); |
|
| 37 | 37 | $dependentTables = ''; |
| 38 | - $dependents = array (); |
|
| 39 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) |
|
| 38 | + $dependents = array(); |
|
| 39 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
| 40 | 40 | { |
| 41 | - $constrant = $objColumn->getFks (); |
|
| 42 | - $variable = $constrant->getNameConstrant () . ZendFrameworkOne::SEPARETOR . $objColumn->getName (); |
|
| 41 | + $constrant = $objColumn->getFks(); |
|
| 42 | + $variable = $constrant->getNameConstrant() . ZendFrameworkOne::SEPARETOR . $objColumn->getName(); |
|
| 43 | 43 | |
| 44 | - $arrClass = array ( |
|
| 45 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
| 44 | + $arrClass = array( |
|
| 45 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
| 46 | 46 | 'DbTable', |
| 47 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
| 47 | + AbstractMaker::getClassName($constrant->getTable()) |
|
| 48 | 48 | ); |
| 49 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
| 49 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
| 50 | 50 | |
| 51 | - $references[] = sprintf ( |
|
| 51 | + $references[] = sprintf( |
|
| 52 | 52 | " |
| 53 | 53 | '%s' => array ( |
| 54 | 54 | 'columns' => '%s' , |
| 55 | 55 | 'refTableClass' => '%s', |
| 56 | 56 | 'refColumns' =>'%s' |
| 57 | 57 | )", |
| 58 | - AbstractMaker::getClassName ( $variable ), |
|
| 59 | - $objColumn->getName (), |
|
| 58 | + AbstractMaker::getClassName($variable), |
|
| 59 | + $objColumn->getName(), |
|
| 60 | 60 | $class, |
| 61 | - $constrant->getColumn () |
|
| 61 | + $constrant->getColumn() |
|
| 62 | 62 | |
| 63 | 63 | ); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if ( sizeof ( $references ) > 0 ) |
|
| 66 | + if (sizeof($references) > 0) |
|
| 67 | 67 | { |
| 68 | 68 | $referenceMap = "protected \$_referenceMap = array(" . |
| 69 | - join ( ',', $references ) . "\n );"; |
|
| 69 | + join(',', $references) . "\n );"; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
| 72 | + foreach ($dbTable->getDependences() as $objColumn) |
|
| 73 | 73 | { |
| 74 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
| 74 | + foreach ($objColumn->getDependences() as $dependence) |
|
| 75 | 75 | { |
| 76 | - $arrClass = array ( |
|
| 77 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
| 76 | + $arrClass = array( |
|
| 77 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
| 78 | 78 | 'DbTable', |
| 79 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
| 79 | + AbstractMaker::getClassName($dependence->getTable()) |
|
| 80 | 80 | ); |
| 81 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
| 81 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
| 82 | 82 | |
| 83 | - if(!in_array($class,$dependents)){ |
|
| 83 | + if ( ! in_array($class, $dependents)) { |
|
| 84 | 84 | $dependents[] = $class; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ( sizeof ( $dependents ) > 0 ) |
|
| 89 | + if (sizeof($dependents) > 0) |
|
| 90 | 90 | { |
| 91 | 91 | $dependentTables = "protected \$_dependentTables = array(\n '" . |
| 92 | - join ( "',\n '", $dependents ) . "'\n );"; |
|
| 92 | + join("',\n '", $dependents) . "'\n );"; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | - return array ( |
|
| 96 | + return array( |
|
| 97 | 97 | 'referenceMap' => $referenceMap, |
| 98 | 98 | 'dependentTables' => $dependentTables |
| 99 | 99 | ); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @var array |
| 57 | 57 | */ |
| 58 | - private $argv = array (); |
|
| 58 | + private $argv = array(); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -67,57 +67,57 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | private $adapterDriver; |
| 69 | 69 | |
| 70 | - private $frameworkList = array ( |
|
| 71 | - 'none' , |
|
| 72 | - 'zf1' , |
|
| 70 | + private $frameworkList = array( |
|
| 71 | + 'none', |
|
| 72 | + 'zf1', |
|
| 73 | 73 | 'phalcon' |
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | - private $parameterList = array ( |
|
| 77 | - 'init' => 'Creates the necessary configuration file to start using the orm-generator.' , |
|
| 78 | - 'name-ini' => 'reference to another .ini file configuration (relative path).' , |
|
| 79 | - 'config-env' => 'orm-generator configuration environment.' , |
|
| 80 | - 'framework' => 'name framework used, which has the contents of the database configurations and framework template.' , |
|
| 81 | - 'driver' => 'database driver name (Ex.: pgsql).' , |
|
| 82 | - 'database' => 'database name.' , |
|
| 83 | - 'schema' => 'database schema name (one or more than one).' , |
|
| 84 | - 'tables' => 'table name (parameter can be used more then once).' , |
|
| 85 | - 'optional-classes' => 'List of optional Predefined classes to be created (Consult in github the list of each framework).' , |
|
| 86 | - 'clean-trash' => 'delete all files that do not belong to your Database due' , |
|
| 87 | - 'status' => 'show status of implementation carried out after completing the process.' , |
|
| 88 | - 'version' => 'shows the version of orm-generator.' , |
|
| 89 | - 'help' => "help command explaining all the options and manner of use." , |
|
| 90 | - 'path' => "specify where to create the files (default is current directory)." , |
|
| 91 | - 'update' => "Upgrade to latest version." , |
|
| 76 | + private $parameterList = array( |
|
| 77 | + 'init' => 'Creates the necessary configuration file to start using the orm-generator.', |
|
| 78 | + 'name-ini' => 'reference to another .ini file configuration (relative path).', |
|
| 79 | + 'config-env' => 'orm-generator configuration environment.', |
|
| 80 | + 'framework' => 'name framework used, which has the contents of the database configurations and framework template.', |
|
| 81 | + 'driver' => 'database driver name (Ex.: pgsql).', |
|
| 82 | + 'database' => 'database name.', |
|
| 83 | + 'schema' => 'database schema name (one or more than one).', |
|
| 84 | + 'tables' => 'table name (parameter can be used more then once).', |
|
| 85 | + 'optional-classes' => 'List of optional Predefined classes to be created (Consult in github the list of each framework).', |
|
| 86 | + 'clean-trash' => 'delete all files that do not belong to your Database due', |
|
| 87 | + 'status' => 'show status of implementation carried out after completing the process.', |
|
| 88 | + 'version' => 'shows the version of orm-generator.', |
|
| 89 | + 'help' => "help command explaining all the options and manner of use.", |
|
| 90 | + 'path' => "specify where to create the files (default is current directory).", |
|
| 91 | + 'update' => "Upgrade to latest version.", |
|
| 92 | 92 | 'download' => "download the reported version (ex. --download=1.5.0). " |
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | - public function __construct ( $argv , $basePath , $numArgs ) |
|
| 95 | + public function __construct($argv, $basePath, $numArgs) |
|
| 96 | 96 | { |
| 97 | - if ( array_key_exists ( 'help' , $argv ) or ( $numArgs > 1 |
|
| 98 | - && count ( $argv ) < 1 ) |
|
| 97 | + if (array_key_exists('help', $argv) or ($numArgs > 1 |
|
| 98 | + && count($argv) < 1) |
|
| 99 | 99 | ) |
| 100 | 100 | { |
| 101 | - die ( $this->getUsage () ); |
|
| 101 | + die ($this->getUsage()); |
|
| 102 | 102 | } |
| 103 | - if ( array_key_exists ( 'version' , $argv ) ) |
|
| 103 | + if (array_key_exists('version', $argv)) |
|
| 104 | 104 | { |
| 105 | - die ( $this->getVersion () ); |
|
| 105 | + die ($this->getVersion()); |
|
| 106 | 106 | } |
| 107 | - if ( array_key_exists ( 'status' , $argv ) ) |
|
| 107 | + if (array_key_exists('status', $argv)) |
|
| 108 | 108 | { |
| 109 | - $argv[ 'status' ] = true; |
|
| 109 | + $argv['status'] = true; |
|
| 110 | 110 | } |
| 111 | - if ( array_key_exists ( 'update' , $argv ) ) |
|
| 111 | + if (array_key_exists('update', $argv)) |
|
| 112 | 112 | { |
| 113 | - die ( $this->update () ); |
|
| 113 | + die ($this->update()); |
|
| 114 | 114 | } |
| 115 | - if ( array_key_exists ( 'download' , $argv ) ) |
|
| 115 | + if (array_key_exists('download', $argv)) |
|
| 116 | 116 | { |
| 117 | - die ( $this->download ( $argv[ 'download' ] ) ); |
|
| 117 | + die ($this->download($argv['download'])); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
| 120 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return string |
| 127 | 127 | */ |
| 128 | - public function getUsage () |
|
| 128 | + public function getUsage() |
|
| 129 | 129 | { |
| 130 | - $version = $this->getVersion (); |
|
| 131 | - $list = $this->renderParam (); |
|
| 130 | + $version = $this->getVersion(); |
|
| 131 | + $list = $this->renderParam(); |
|
| 132 | 132 | |
| 133 | 133 | return <<<EOF |
| 134 | 134 | parameters: |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | EOF; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function renderParam () |
|
| 142 | + public function renderParam() |
|
| 143 | 143 | { |
| 144 | 144 | $return = ""; |
| 145 | - foreach ( $this->parameterList as $param => $desc ) |
|
| 145 | + foreach ($this->parameterList as $param => $desc) |
|
| 146 | 146 | { |
| 147 | - if ( strlen ( $param ) < 5 ) |
|
| 147 | + if (strlen($param) < 5) |
|
| 148 | 148 | { |
| 149 | 149 | $return .= "\t--" . $param . "\t\t: " . $desc . "\n"; |
| 150 | 150 | } else |
@@ -157,21 +157,21 @@ discard block |
||
| 157 | 157 | return $return; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function update () |
|
| 160 | + public function update() |
|
| 161 | 161 | { |
| 162 | 162 | $update = new Update(); |
| 163 | - $update->update () |
|
| 164 | - ->modifyTempName (); |
|
| 163 | + $update->update() |
|
| 164 | + ->modifyTempName(); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function download ( $version ) |
|
| 167 | + public function download($version) |
|
| 168 | 168 | { |
| 169 | 169 | $update = new Update(); |
| 170 | - $update->downloadVersion ( $version ) |
|
| 171 | - ->modifyTempName (); |
|
| 170 | + $update->downloadVersion($version) |
|
| 171 | + ->modifyTempName(); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public function getVersion () |
|
| 174 | + public function getVersion() |
|
| 175 | 175 | { |
| 176 | 176 | $version = new Version(); |
| 177 | 177 | |
@@ -187,31 +187,31 @@ discard block |
||
| 187 | 187 | * @return array |
| 188 | 188 | * @throws \Exception |
| 189 | 189 | */ |
| 190 | - private function parseConfig ( $basePath , $argv ) |
|
| 190 | + private function parseConfig($basePath, $argv) |
|
| 191 | 191 | { |
| 192 | 192 | $this->_basePath = $basePath; |
| 193 | 193 | |
| 194 | - $configIni = isset( $argv[ 'name-ini' ] ) |
|
| 195 | - ? $argv[ 'name-ini' ] |
|
| 194 | + $configIni = isset($argv['name-ini']) |
|
| 195 | + ? $argv['name-ini'] |
|
| 196 | 196 | : $this->_basePath |
| 197 | 197 | . $this->configIniDefault; |
| 198 | 198 | |
| 199 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
| 200 | - $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
|
| 199 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
| 200 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
| 201 | 201 | |
| 202 | - if ( ! isset( $configCurrent[ 'framework' ] ) ) |
|
| 202 | + if ( ! isset($configCurrent['framework'])) |
|
| 203 | 203 | { |
| 204 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
| 204 | + throw new \Exception("configure which framework you want to use! \n"); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( ! in_array ( $configCurrent[ 'framework' ] , $this->frameworkList ) ) |
|
| 207 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) |
|
| 208 | 208 | { |
| 209 | - $frameworks = implode ( "\n\t" , $this->frameworkList ); |
|
| 210 | - throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks |
|
| 211 | - . "\n\033[0m" ); |
|
| 209 | + $frameworks = implode("\n\t", $this->frameworkList); |
|
| 210 | + throw new \Exception("list of frameworks: \n\t\033[1;33m" . $frameworks |
|
| 211 | + . "\n\033[0m"); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - return $argv + array_filter ( $configCurrent ); |
|
| 214 | + return $argv + array_filter($configCurrent); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -221,24 +221,24 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @return string |
| 223 | 223 | */ |
| 224 | - private static function parseConfigEnv ( $configTemp , $argv ) |
|
| 224 | + private static function parseConfigEnv($configTemp, $argv) |
|
| 225 | 225 | { |
| 226 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) |
|
| 227 | - ? $configTemp[ key ( |
|
| 226 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) |
|
| 227 | + ? $configTemp[key( |
|
| 228 | 228 | $configTemp |
| 229 | - ) ][ 'config-env' ] : null; |
|
| 229 | + )]['config-env'] : null; |
|
| 230 | 230 | |
| 231 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] |
|
| 231 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] |
|
| 232 | 232 | : $thisSection; |
| 233 | 233 | |
| 234 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) |
|
| 234 | + if (isset($configTemp[$thisSection]['extends'])) |
|
| 235 | 235 | { |
| 236 | 236 | #faz marge da config principal com a config extendida |
| 237 | - return $configTemp[ $thisSection ] |
|
| 238 | - + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
| 237 | + return $configTemp[$thisSection] |
|
| 238 | + + $configTemp[$configTemp[$thisSection]['extends']]; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - return $configTemp[ key ( $configTemp ) ]; |
|
| 241 | + return $configTemp[key($configTemp)]; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -252,32 +252,32 @@ discard block |
||
| 252 | 252 | * @throws \Exception |
| 253 | 253 | * @return array |
| 254 | 254 | */ |
| 255 | - protected function loadIniFile ( $filename ) |
|
| 255 | + protected function loadIniFile($filename) |
|
| 256 | 256 | { |
| 257 | - if ( ! is_file ( $filename ) ) |
|
| 257 | + if ( ! is_file($filename)) |
|
| 258 | 258 | { |
| 259 | - throw new \Exception( "\033[0;31mError: configuration file does not exist! \033[0m\n" ); |
|
| 259 | + throw new \Exception("\033[0;31mError: configuration file does not exist! \033[0m\n"); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $loaded = parse_ini_file ( $filename , true ); |
|
| 263 | - $iniArray = array (); |
|
| 264 | - foreach ( $loaded as $key => $data ) |
|
| 262 | + $loaded = parse_ini_file($filename, true); |
|
| 263 | + $iniArray = array(); |
|
| 264 | + foreach ($loaded as $key => $data) |
|
| 265 | 265 | { |
| 266 | - $pieces = explode ( $this->sectionSeparator , $key ); |
|
| 267 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
| 268 | - switch ( count ( $pieces ) ) |
|
| 266 | + $pieces = explode($this->sectionSeparator, $key); |
|
| 267 | + $thisSection = trim($pieces[0]); |
|
| 268 | + switch (count($pieces)) |
|
| 269 | 269 | { |
| 270 | 270 | case 1: |
| 271 | - $iniArray[ $thisSection ] = $data; |
|
| 271 | + $iniArray[$thisSection] = $data; |
|
| 272 | 272 | break; |
| 273 | 273 | |
| 274 | 274 | case 2: |
| 275 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
| 276 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ) , $data ); |
|
| 275 | + $extendedSection = trim($pieces[1]); |
|
| 276 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
| 277 | 277 | break; |
| 278 | 278 | |
| 279 | 279 | default: |
| 280 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
| 280 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
@@ -290,16 +290,16 @@ discard block |
||
| 290 | 290 | * @return \Classes\AdapterConfig\AbstractAdapter |
| 291 | 291 | * |
| 292 | 292 | */ |
| 293 | - private function factoryConfig () |
|
| 293 | + private function factoryConfig() |
|
| 294 | 294 | { |
| 295 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) |
|
| 295 | + switch (strtolower($this->argv['framework'])) |
|
| 296 | 296 | { |
| 297 | 297 | case 'zf1': |
| 298 | - return new ZendFrameworkOne( $this->argv ); |
|
| 298 | + return new ZendFrameworkOne($this->argv); |
|
| 299 | 299 | case 'phalcon': |
| 300 | - return new Phalcon( $this->argv ); |
|
| 300 | + return new Phalcon($this->argv); |
|
| 301 | 301 | default: |
| 302 | - return new None( $this->argv ); |
|
| 302 | + return new None($this->argv); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | } |
@@ -311,33 +311,33 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @return AdaptersDriver\AbsractAdapter |
| 313 | 313 | */ |
| 314 | - private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
|
| 314 | + private function factoryDriver(AdapterConfig\AbstractAdapter $config) |
|
| 315 | 315 | { |
| 316 | - switch ( $this->argv[ 'driver' ] ) |
|
| 316 | + switch ($this->argv['driver']) |
|
| 317 | 317 | { |
| 318 | 318 | case 'pgsql': |
| 319 | 319 | case 'pdo_pgsql': |
| 320 | - return new Pgsql( $config ); |
|
| 320 | + return new Pgsql($config); |
|
| 321 | 321 | case 'mysql': |
| 322 | 322 | case 'pdo_mysql': |
| 323 | - return new Mysql( $config ); |
|
| 323 | + return new Mysql($config); |
|
| 324 | 324 | case 'mssql': |
| 325 | - return new Mssql( $config ); |
|
| 325 | + return new Mssql($config); |
|
| 326 | 326 | case 'dblib': |
| 327 | - return new Dblib( $config ); |
|
| 327 | + return new Dblib($config); |
|
| 328 | 328 | case 'sqlsrv': |
| 329 | - return new Sqlsrv( $config ); |
|
| 329 | + return new Sqlsrv($config); |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | 334 | * @return AdapterConfig\AbstractAdapter |
| 335 | 335 | */ |
| 336 | - public function getAdapterConfig () |
|
| 336 | + public function getAdapterConfig() |
|
| 337 | 337 | { |
| 338 | - if ( ! $this->adapterConfig instanceof AbstractAdapter ) |
|
| 338 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) |
|
| 339 | 339 | { |
| 340 | - $this->adapterConfig = $this->factoryConfig (); |
|
| 340 | + $this->adapterConfig = $this->factoryConfig(); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | return $this->adapterConfig; |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | /** |
| 347 | 347 | * @return AdaptersDriver\AbsractAdapter |
| 348 | 348 | */ |
| 349 | - public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
|
| 349 | + public function getAdapterDriver(AdapterConfig\AbstractAdapter $config) |
|
| 350 | 350 | { |
| 351 | - if ( ! $this->adapterDriver ) |
|
| 351 | + if ( ! $this->adapterDriver) |
|
| 352 | 352 | { |
| 353 | - $this->adapterDriver = $this->factoryDriver ( $config ); |
|
| 353 | + $this->adapterDriver = $this->factoryDriver($config); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | return $this->adapterDriver; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | const SEPARETOR = "_"; |
| 26 | 26 | |
| 27 | - protected function init () |
|
| 27 | + protected function init() |
|
| 28 | 28 | { |
| 29 | 29 | } |
| 30 | 30 | |
@@ -33,50 +33,50 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return array |
| 35 | 35 | */ |
| 36 | - protected function getParams () |
|
| 36 | + protected function getParams() |
|
| 37 | 37 | { |
| 38 | - if ( ! $this->config or ! $this->isValidFrameworkFiles () ) |
|
| 38 | + if ( ! $this->config or ! $this->isValidFrameworkFiles()) |
|
| 39 | 39 | { |
| 40 | - return array (); |
|
| 40 | + return array(); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - return array ( |
|
| 43 | + return array( |
|
| 44 | 44 | //Driver do banco de dados |
| 45 | - 'driver' => $this->config[ 'adapter' ] , |
|
| 45 | + 'driver' => $this->config['adapter'], |
|
| 46 | 46 | //Nome do banco de dados |
| 47 | - 'database' => $this->config[ 'params' ][ 'dbname' ] , |
|
| 47 | + 'database' => $this->config['params']['dbname'], |
|
| 48 | 48 | //Host do banco |
| 49 | - 'host' => $this->config[ 'params' ][ 'host' ] , |
|
| 49 | + 'host' => $this->config['params']['host'], |
|
| 50 | 50 | //Port do banco |
| 51 | - 'port' => isset( $this->config[ 'params' ][ 'port' ] ) |
|
| 52 | - ? $this->config[ 'params' ][ 'port' ] : '' , |
|
| 51 | + 'port' => isset($this->config['params']['port']) |
|
| 52 | + ? $this->config['params']['port'] : '', |
|
| 53 | 53 | //usuario do banco |
| 54 | - 'username' => $this->config[ 'params' ][ 'username' ] , |
|
| 54 | + 'username' => $this->config['params']['username'], |
|
| 55 | 55 | //senha do banco |
| 56 | - 'password' => $this->config[ 'params' ][ 'password' ] , |
|
| 56 | + 'password' => $this->config['params']['password'], |
|
| 57 | 57 | ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - protected function parseFrameworkConfig () |
|
| 60 | + protected function parseFrameworkConfig() |
|
| 61 | 61 | { |
| 62 | - if ( ! $this->isValidFrameworkFiles () ) |
|
| 62 | + if ( ! $this->isValidFrameworkFiles()) |
|
| 63 | 63 | { |
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $frameworkIni = $this->getFrameworkIni (); |
|
| 67 | + $frameworkIni = $this->getFrameworkIni(); |
|
| 68 | 68 | |
| 69 | 69 | require_once 'Zend/Config/Ini.php'; |
| 70 | 70 | |
| 71 | 71 | $objConfig = new \Zend_Config_Ini( |
| 72 | - realpath ( $frameworkIni ) , $this->getEnvironment () |
|
| 72 | + realpath($frameworkIni), $this->getEnvironment() |
|
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - $arrConfig = $objConfig->toArray (); |
|
| 75 | + $arrConfig = $objConfig->toArray(); |
|
| 76 | 76 | |
| 77 | - if ( isset( $arrConfig[ 'resources' ][ 'db' ] ) ) |
|
| 77 | + if (isset($arrConfig['resources']['db'])) |
|
| 78 | 78 | { |
| 79 | - $this->config = $arrConfig[ 'resources' ][ 'db' ]; |
|
| 79 | + $this->config = $arrConfig['resources']['db']; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -85,27 +85,27 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
| 87 | 87 | */ |
| 88 | - public function getMakeFileInstances () |
|
| 88 | + public function getMakeFileInstances() |
|
| 89 | 89 | { |
| 90 | 90 | |
| 91 | - $instances = array (); |
|
| 92 | - if ( $this->hasOptionalClasses () ) |
|
| 91 | + $instances = array(); |
|
| 92 | + if ($this->hasOptionalClasses()) |
|
| 93 | 93 | { |
| 94 | - foreach ( $this->getOptionalClasses () as $optionalClass ) |
|
| 94 | + foreach ($this->getOptionalClasses() as $optionalClass) |
|
| 95 | 95 | { |
| 96 | - $Name = ucfirst ( $optionalClass ); |
|
| 96 | + $Name = ucfirst($optionalClass); |
|
| 97 | 97 | $className = "Classes\\AdapterMakerFile\\ZendFrameworkOne\\{$Name}"; |
| 98 | - if(method_exists($className,'getInstance')){ |
|
| 99 | - $instances[] = $className::getInstance (); |
|
| 98 | + if (method_exists($className, 'getInstance')) { |
|
| 99 | + $instances[] = $className::getInstance(); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - return array_merge ( array ( |
|
| 105 | - DbTable::getInstance () , |
|
| 106 | - Entity::getInstance () , |
|
| 107 | - Model::getInstance () |
|
| 108 | - ) , $instances ); |
|
| 104 | + return array_merge(array( |
|
| 105 | + DbTable::getInstance(), |
|
| 106 | + Entity::getInstance(), |
|
| 107 | + Model::getInstance() |
|
| 108 | + ), $instances); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | } |
@@ -16,90 +16,90 @@ discard block |
||
| 16 | 16 | abstract class AbstractAdapter |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - protected $arrConfig = array ( |
|
| 19 | + protected $arrConfig = array( |
|
| 20 | 20 | ############################# DATABASE |
| 21 | 21 | //Driver do banco de dados |
| 22 | - 'driver' => null , |
|
| 22 | + 'driver' => null, |
|
| 23 | 23 | //Nome do banco de dados |
| 24 | - 'database' => null , |
|
| 24 | + 'database' => null, |
|
| 25 | 25 | //Host do banco |
| 26 | - 'host' => 'localhost' , |
|
| 26 | + 'host' => 'localhost', |
|
| 27 | 27 | //Port do banco |
| 28 | - 'port' => '' , |
|
| 28 | + 'port' => '', |
|
| 29 | 29 | //usuario do banco |
| 30 | - 'username' => null , |
|
| 30 | + 'username' => null, |
|
| 31 | 31 | //senha do banco |
| 32 | - 'password' => null , |
|
| 32 | + 'password' => null, |
|
| 33 | 33 | // lista de schemas do banco de dados |
| 34 | - 'schema' => array () , |
|
| 35 | - 'version' => '' , |
|
| 36 | - 'socket' => null , |
|
| 34 | + 'schema' => array(), |
|
| 35 | + 'version' => '', |
|
| 36 | + 'socket' => null, |
|
| 37 | 37 | |
| 38 | 38 | ########################### DOCS |
| 39 | 39 | // autor que gerou o script |
| 40 | - 'author' => "Pedro" , |
|
| 41 | - 'license' => "New BSD License" , |
|
| 42 | - 'copyright' => "ORM Generator - Pedro151" , |
|
| 43 | - 'link' => 'https://github.com/pedro151/orm-generator' , |
|
| 44 | - 'version' => '' , |
|
| 40 | + 'author' => "Pedro", |
|
| 41 | + 'license' => "New BSD License", |
|
| 42 | + 'copyright' => "ORM Generator - Pedro151", |
|
| 43 | + 'link' => 'https://github.com/pedro151/orm-generator', |
|
| 44 | + 'version' => '', |
|
| 45 | 45 | // data que foi gerado o script |
| 46 | - 'last_modify' => null , |
|
| 46 | + 'last_modify' => null, |
|
| 47 | 47 | |
| 48 | 48 | ########################## Ambiente/Arquivos |
| 49 | 49 | |
| 50 | 50 | // Nome do framework para o adapter |
| 51 | - 'framework' => null , |
|
| 51 | + 'framework' => null, |
|
| 52 | 52 | // namespace das classes |
| 53 | - 'namespace' => "" , |
|
| 53 | + 'namespace' => "", |
|
| 54 | 54 | // caminho onde os arquivos devem ser criados |
| 55 | - 'path' => 'models' , |
|
| 55 | + 'path' => 'models', |
|
| 56 | 56 | // flag para gerar pasta com o nome do driver do banco de dados |
| 57 | - 'folder-database' => 0 , |
|
| 57 | + 'folder-database' => 0, |
|
| 58 | 58 | // string com o nome da pastar personalizada |
| 59 | - 'folder-name' => '' , |
|
| 59 | + 'folder-name' => '', |
|
| 60 | 60 | |
| 61 | 61 | 'clean-trash' => false, |
| 62 | 62 | |
| 63 | 63 | ############################## Comandos adicionais |
| 64 | 64 | //flag para mostrar o status da execução ao termino do processo |
| 65 | - 'status' => false , |
|
| 65 | + 'status' => false, |
|
| 66 | 66 | // flags para criar todas as tabelas ou nao |
| 67 | - 'tables' => array () , |
|
| 67 | + 'tables' => array(), |
|
| 68 | 68 | // lista de Classes opcionais pre-definidas para serem criadas |
| 69 | - 'optional-classes'=> array (), |
|
| 69 | + 'optional-classes'=> array(), |
|
| 70 | 70 | //Lista de tabelas a serem ignoradas |
| 71 | - 'ignoreTable' => array () , |
|
| 71 | + 'ignoreTable' => array(), |
|
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @var string[] um array com todos os campos obrigatorios |
| 76 | 76 | */ |
| 77 | - protected $attRequered = array ( |
|
| 78 | - 'driver' => true , |
|
| 79 | - 'database' => true , |
|
| 80 | - 'host' => true , |
|
| 81 | - 'username' => true , |
|
| 77 | + protected $attRequered = array( |
|
| 78 | + 'driver' => true, |
|
| 79 | + 'database' => true, |
|
| 80 | + 'host' => true, |
|
| 81 | + 'username' => true, |
|
| 82 | 82 | 'path' => true |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - protected $arrFunc = array (); |
|
| 85 | + protected $arrFunc = array(); |
|
| 86 | 86 | |
| 87 | - private $framworkFiles = array (); |
|
| 87 | + private $framworkFiles = array(); |
|
| 88 | 88 | |
| 89 | - public $reservedWord = array (); |
|
| 89 | + public $reservedWord = array(); |
|
| 90 | 90 | |
| 91 | - private static $dataTypesDefault = array ( |
|
| 92 | - 'int' => 'int' , |
|
| 93 | - 'float' => 'float' , |
|
| 94 | - 'string' => 'string' , |
|
| 95 | - 'text' => 'string' , |
|
| 96 | - 'date' => 'date' , |
|
| 97 | - 'datetime' => 'datetime' , |
|
| 98 | - 'timestamp' => 'timestamp' , |
|
| 91 | + private static $dataTypesDefault = array( |
|
| 92 | + 'int' => 'int', |
|
| 93 | + 'float' => 'float', |
|
| 94 | + 'string' => 'string', |
|
| 95 | + 'text' => 'string', |
|
| 96 | + 'date' => 'date', |
|
| 97 | + 'datetime' => 'datetime', |
|
| 98 | + 'timestamp' => 'timestamp', |
|
| 99 | 99 | 'boolean' => 'boolean' |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - protected $dataTypes = array (); |
|
| 102 | + protected $dataTypes = array(); |
|
| 103 | 103 | |
| 104 | 104 | const SEPARETOR = ""; |
| 105 | 105 | |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - protected function checkConfig () |
|
| 111 | + protected function checkConfig() |
|
| 112 | 112 | { |
| 113 | - if ( array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ) ) |
|
| 113 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) |
|
| 114 | 114 | { |
| 115 | 115 | return false; |
| 116 | 116 | } |
@@ -123,33 +123,33 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return array |
| 125 | 125 | */ |
| 126 | - abstract protected function getParams (); |
|
| 126 | + abstract protected function getParams(); |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * Popula as config do generater com as configuraçoes do framework |
| 130 | 130 | * |
| 131 | 131 | * @return mixed |
| 132 | 132 | */ |
| 133 | - abstract protected function parseFrameworkConfig (); |
|
| 133 | + abstract protected function parseFrameworkConfig(); |
|
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * Cria Instancias dos arquivos que devem ser gerados |
| 137 | 137 | * |
| 138 | 138 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
| 139 | 139 | */ |
| 140 | - abstract public function getMakeFileInstances (); |
|
| 140 | + abstract public function getMakeFileInstances(); |
|
| 141 | 141 | |
| 142 | - abstract protected function init (); |
|
| 142 | + abstract protected function init(); |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * retorna a base do Namespace |
| 146 | 146 | * |
| 147 | 147 | * @return array |
| 148 | 148 | */ |
| 149 | - protected function getBaseNamespace () |
|
| 149 | + protected function getBaseNamespace() |
|
| 150 | 150 | { |
| 151 | - return array ( |
|
| 152 | - $this->arrConfig[ 'namespace' ] , |
|
| 151 | + return array( |
|
| 152 | + $this->arrConfig['namespace'], |
|
| 153 | 153 | 'Model' |
| 154 | 154 | ); |
| 155 | 155 | } |
@@ -160,54 +160,54 @@ discard block |
||
| 160 | 160 | * @return mixed |
| 161 | 161 | */ |
| 162 | 162 | |
| 163 | - public function createClassNamespace ( $table ) |
|
| 163 | + public function createClassNamespace($table) |
|
| 164 | 164 | { |
| 165 | - $arrNames = $this->getBaseNamespace (); |
|
| 165 | + $arrNames = $this->getBaseNamespace(); |
|
| 166 | 166 | |
| 167 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
| 168 | - && $this->arrConfig[ 'folder-database' ] |
|
| 167 | + if (isset($this->arrConfig['folder-database']) |
|
| 168 | + && $this->arrConfig['folder-database'] |
|
| 169 | 169 | ) |
| 170 | 170 | { |
| 171 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
| 171 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
| 175 | - && $this->arrConfig[ 'folder-name' ] |
|
| 174 | + if (isset($this->arrConfig['folder-name']) |
|
| 175 | + && $this->arrConfig['folder-name'] |
|
| 176 | 176 | ) |
| 177 | 177 | { |
| 178 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
| 178 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( $table->hasSchema () ) |
|
| 181 | + if ($table->hasSchema()) |
|
| 182 | 182 | { |
| 183 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getSchema () ) ); |
|
| 183 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); |
|
| 184 | 184 | } else |
| 185 | 185 | { |
| 186 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getDatabase () ) ); |
|
| 186 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - return implode ( static::SEPARETOR , array_filter ( $arrNames ) ); |
|
| 189 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - public function __construct ( $array ) |
|
| 192 | + public function __construct($array) |
|
| 193 | 193 | { |
| 194 | 194 | $this->dataTypes = $this->dataTypes + self::$dataTypesDefault; |
| 195 | - $array += array ( |
|
| 196 | - 'version' => Config::$version , |
|
| 197 | - 'author' => ucfirst ( get_current_user () ) , |
|
| 198 | - 'last_modify' => date ( "d-m-Y" ) |
|
| 195 | + $array += array( |
|
| 196 | + 'version' => Config::$version, |
|
| 197 | + 'author' => ucfirst(get_current_user()), |
|
| 198 | + 'last_modify' => date("d-m-Y") |
|
| 199 | 199 | ); |
| 200 | 200 | |
| 201 | - $this->setFrameworkFiles ( $array ); |
|
| 202 | - $this->parseFrameworkConfig (); |
|
| 203 | - $this->setParams ( $this->getParams () ); |
|
| 204 | - $this->setParams ( $array ); |
|
| 205 | - $this->init (); |
|
| 206 | - $this->validTableNames (); |
|
| 207 | - if ( ! $this->isValid () ) |
|
| 201 | + $this->setFrameworkFiles($array); |
|
| 202 | + $this->parseFrameworkConfig(); |
|
| 203 | + $this->setParams($this->getParams()); |
|
| 204 | + $this->setParams($array); |
|
| 205 | + $this->init(); |
|
| 206 | + $this->validTableNames(); |
|
| 207 | + if ( ! $this->isValid()) |
|
| 208 | 208 | { |
| 209 | - $var = array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ); |
|
| 210 | - throw new Exception( $var ); |
|
| 209 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
| 210 | + throw new Exception($var); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -216,43 +216,43 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @param $array |
| 218 | 218 | */ |
| 219 | - public function setFrameworkFiles ( $array ) |
|
| 219 | + public function setFrameworkFiles($array) |
|
| 220 | 220 | { |
| 221 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) |
|
| 222 | - ? $array[ 'framework-path-library' ] : null; |
|
| 221 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) |
|
| 222 | + ? $array['framework-path-library'] : null; |
|
| 223 | 223 | |
| 224 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) |
|
| 225 | - ? $array[ 'framework-ini' ] : null; |
|
| 224 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) |
|
| 225 | + ? $array['framework-ini'] : null; |
|
| 226 | 226 | |
| 227 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) |
|
| 228 | - ? $array[ 'environment' ] : 'production'; |
|
| 227 | + $this->framworkFiles['environment'] = isset($array['environment']) |
|
| 228 | + ? $array['environment'] : 'production'; |
|
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - protected function isValidFrameworkFiles () |
|
| 232 | + protected function isValidFrameworkFiles() |
|
| 233 | 233 | { |
| 234 | - if ( ! is_file ( $this->framworkFiles[ 'ini' ] ) ) |
|
| 234 | + if ( ! is_file($this->framworkFiles['ini'])) |
|
| 235 | 235 | { |
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if ( ! is_dir ( $this->framworkFiles[ 'library' ] ) ) |
|
| 239 | + if ( ! is_dir($this->framworkFiles['library'])) |
|
| 240 | 240 | { |
| 241 | 241 | return false; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if ( ! isset ( $this->framworkFiles[ 'environment' ] ) |
|
| 245 | - or empty( $this->framworkFiles[ 'environment' ] ) |
|
| 244 | + if ( ! isset ($this->framworkFiles['environment']) |
|
| 245 | + or empty($this->framworkFiles['environment']) |
|
| 246 | 246 | ) |
| 247 | 247 | { |
| 248 | 248 | return false; |
| 249 | 249 | } |
| 250 | - set_include_path ( |
|
| 251 | - implode ( |
|
| 252 | - PATH_SEPARATOR , |
|
| 253 | - array ( |
|
| 254 | - realpath ( $this->framworkFiles[ 'library' ] ) , |
|
| 255 | - get_include_path () , |
|
| 250 | + set_include_path( |
|
| 251 | + implode( |
|
| 252 | + PATH_SEPARATOR, |
|
| 253 | + array( |
|
| 254 | + realpath($this->framworkFiles['library']), |
|
| 255 | + get_include_path(), |
|
| 256 | 256 | ) |
| 257 | 257 | ) |
| 258 | 258 | ); |
@@ -260,119 +260,119 @@ discard block |
||
| 260 | 260 | return true; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - protected function getFrameworkIni () |
|
| 263 | + protected function getFrameworkIni() |
|
| 264 | 264 | { |
| 265 | - return $this->framworkFiles[ 'ini' ]; |
|
| 265 | + return $this->framworkFiles['ini']; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - protected function getEnvironment () |
|
| 268 | + protected function getEnvironment() |
|
| 269 | 269 | { |
| 270 | - return $this->framworkFiles[ 'environment' ]; |
|
| 270 | + return $this->framworkFiles['environment']; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
| 275 | 275 | */ |
| 276 | - protected function isValid () |
|
| 276 | + protected function isValid() |
|
| 277 | 277 | { |
| 278 | - return $this->checkConfig (); |
|
| 278 | + return $this->checkConfig(); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - private function setParams ( $array ) |
|
| 281 | + private function setParams($array) |
|
| 282 | 282 | { |
| 283 | - if ( count ( $array ) > 0 ) |
|
| 283 | + if (count($array) > 0) |
|
| 284 | 284 | { |
| 285 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
| 285 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | - public function getDatabase () |
|
| 292 | + public function getDatabase() |
|
| 293 | 293 | { |
| 294 | - return $this->arrConfig[ 'database' ]; |
|
| 294 | + return $this->arrConfig['database']; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * @return bool |
| 299 | 299 | */ |
| 300 | - public function hasSchemas () |
|
| 300 | + public function hasSchemas() |
|
| 301 | 301 | { |
| 302 | - return ! empty ( $this->arrConfig[ 'schema' ] ); |
|
| 302 | + return ! empty ($this->arrConfig['schema']); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | 306 | * @return string[] |
| 307 | 307 | */ |
| 308 | - public function getSchemas () |
|
| 308 | + public function getSchemas() |
|
| 309 | 309 | { |
| 310 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) |
|
| 310 | + if (is_string($this->arrConfig['schema'])) |
|
| 311 | 311 | { |
| 312 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
| 312 | + return array($this->arrConfig['schema']); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - return $this->arrConfig[ 'schema' ]; |
|
| 315 | + return $this->arrConfig['schema']; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - public function setSchema ( $schema ) |
|
| 318 | + public function setSchema($schema) |
|
| 319 | 319 | { |
| 320 | - $this->arrConfig[ 'schema' ] = $schema; |
|
| 320 | + $this->arrConfig['schema'] = $schema; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | 324 | * @return string |
| 325 | 325 | */ |
| 326 | - public function getHost () |
|
| 326 | + public function getHost() |
|
| 327 | 327 | { |
| 328 | - return $this->arrConfig[ 'host' ]; |
|
| 328 | + return $this->arrConfig['host']; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | 332 | * @return int |
| 333 | 333 | */ |
| 334 | - public function getPort () |
|
| 334 | + public function getPort() |
|
| 335 | 335 | { |
| 336 | - return $this->arrConfig[ 'port' ]; |
|
| 336 | + return $this->arrConfig['port']; |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | 340 | * @return boolean |
| 341 | 341 | */ |
| 342 | - public function hasPort () |
|
| 342 | + public function hasPort() |
|
| 343 | 343 | { |
| 344 | - return ! empty( $this->arrConfig[ 'port' ] ); |
|
| 344 | + return ! empty($this->arrConfig['port']); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
| 348 | 348 | * @return boolean |
| 349 | 349 | */ |
| 350 | - public function isCleanTrash(){ |
|
| 351 | - return (boolean) $this->arrConfig[ 'clean-trash' ]; |
|
| 350 | + public function isCleanTrash() { |
|
| 351 | + return (boolean) $this->arrConfig['clean-trash']; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | 355 | * @return string |
| 356 | 356 | */ |
| 357 | - public function getSocket () |
|
| 357 | + public function getSocket() |
|
| 358 | 358 | { |
| 359 | - return $this->arrConfig[ 'socket' ]; |
|
| 359 | + return $this->arrConfig['socket']; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | 363 | * @return string |
| 364 | 364 | */ |
| 365 | - public function getUser () |
|
| 365 | + public function getUser() |
|
| 366 | 366 | { |
| 367 | - return $this->arrConfig[ 'username' ]; |
|
| 367 | + return $this->arrConfig['username']; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
| 371 | 371 | * @return string |
| 372 | 372 | */ |
| 373 | - public function getPassword () |
|
| 373 | + public function getPassword() |
|
| 374 | 374 | { |
| 375 | - return $this->arrConfig[ 'password' ]; |
|
| 375 | + return $this->arrConfig['password']; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | /** |
@@ -380,11 +380,11 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return string |
| 382 | 382 | */ |
| 383 | - public function replaceReservedWord ( $palavra ) |
|
| 383 | + public function replaceReservedWord($palavra) |
|
| 384 | 384 | { |
| 385 | - if ( isset( $this->reservedWord[ strtolower ( $palavra ) ] ) ) |
|
| 385 | + if (isset($this->reservedWord[strtolower($palavra)])) |
|
| 386 | 386 | { |
| 387 | - return $this->reservedWord[ strtolower ( $palavra ) ]; |
|
| 387 | + return $this->reservedWord[strtolower($palavra)]; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | return $palavra; |
@@ -393,15 +393,15 @@ discard block |
||
| 393 | 393 | /** |
| 394 | 394 | * @return bool |
| 395 | 395 | */ |
| 396 | - public function isStatusEnabled () |
|
| 396 | + public function isStatusEnabled() |
|
| 397 | 397 | { |
| 398 | - return (bool) $this->arrConfig[ 'status' ]; |
|
| 398 | + return (bool) $this->arrConfig['status']; |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - public function validTableNames () |
|
| 401 | + public function validTableNames() |
|
| 402 | 402 | { |
| 403 | - $matches = preg_grep ( '*\.*' , $this->getTablesName () ); |
|
| 404 | - if ( count ( $matches ) ) |
|
| 403 | + $matches = preg_grep('*\.*', $this->getTablesName()); |
|
| 404 | + if (count($matches)) |
|
| 405 | 405 | { |
| 406 | 406 | die("\033[0;31mError: Table name must not contain the schema.\033[0m\n"); |
| 407 | 407 | } |
@@ -410,49 +410,49 @@ discard block |
||
| 410 | 410 | /** |
| 411 | 411 | * @return bool |
| 412 | 412 | */ |
| 413 | - public function hasTablesName (){ |
|
| 414 | - return ! empty( $this->arrConfig[ 'tables' ] ); |
|
| 413 | + public function hasTablesName() { |
|
| 414 | + return ! empty($this->arrConfig['tables']); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
| 418 | 418 | * @return string[] |
| 419 | 419 | */ |
| 420 | - public function getTablesName () |
|
| 420 | + public function getTablesName() |
|
| 421 | 421 | { |
| 422 | - if ( is_string ( $this->arrConfig[ 'tables' ] ) ) |
|
| 422 | + if (is_string($this->arrConfig['tables'])) |
|
| 423 | 423 | { |
| 424 | - return array ( $this->arrConfig[ 'tables' ] ); |
|
| 424 | + return array($this->arrConfig['tables']); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return $this->arrConfig[ 'tables' ]; |
|
| 427 | + return $this->arrConfig['tables']; |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
| 431 | 431 | * @return string |
| 432 | 432 | */ |
| 433 | - public function getListTablesName(){ |
|
| 434 | - $str = implode("','", $this->getTablesName() ); |
|
| 433 | + public function getListTablesName() { |
|
| 434 | + $str = implode("','", $this->getTablesName()); |
|
| 435 | 435 | return "'$str'"; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | 439 | * @return bool |
| 440 | 440 | */ |
| 441 | - public function hasOptionalClasses (){ |
|
| 442 | - return ! empty( $this->arrConfig[ 'optional-classes' ] ); |
|
| 441 | + public function hasOptionalClasses() { |
|
| 442 | + return ! empty($this->arrConfig['optional-classes']); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | 446 | * @return string[] |
| 447 | 447 | */ |
| 448 | - public function getOptionalClasses () |
|
| 448 | + public function getOptionalClasses() |
|
| 449 | 449 | { |
| 450 | - if ( is_string ( $this->arrConfig[ 'optional-classes' ] ) ) |
|
| 450 | + if (is_string($this->arrConfig['optional-classes'])) |
|
| 451 | 451 | { |
| 452 | - return array ( $this->arrConfig[ 'optional-classes' ] ); |
|
| 452 | + return array($this->arrConfig['optional-classes']); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - return $this->arrConfig[ 'optional-classes' ]; |
|
| 455 | + return $this->arrConfig['optional-classes']; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -460,25 +460,25 @@ discard block |
||
| 460 | 460 | * |
| 461 | 461 | * @return string |
| 462 | 462 | */ |
| 463 | - public function __get ( $str ) |
|
| 463 | + public function __get($str) |
|
| 464 | 464 | { |
| 465 | - $arr = array ( |
|
| 466 | - 'namespace' , |
|
| 467 | - 'framework' , |
|
| 468 | - 'author' , |
|
| 469 | - 'license' , |
|
| 470 | - 'version' , |
|
| 471 | - 'copyright' , |
|
| 472 | - 'link' , |
|
| 473 | - 'last_modify' , |
|
| 474 | - 'path' , |
|
| 475 | - 'folder-database' , |
|
| 465 | + $arr = array( |
|
| 466 | + 'namespace', |
|
| 467 | + 'framework', |
|
| 468 | + 'author', |
|
| 469 | + 'license', |
|
| 470 | + 'version', |
|
| 471 | + 'copyright', |
|
| 472 | + 'link', |
|
| 473 | + 'last_modify', |
|
| 474 | + 'path', |
|
| 475 | + 'folder-database', |
|
| 476 | 476 | 'folder-name' |
| 477 | 477 | ); |
| 478 | 478 | |
| 479 | - if ( in_array ( $str , $arr ) ) |
|
| 479 | + if (in_array($str, $arr)) |
|
| 480 | 480 | { |
| 481 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
| 481 | + return $this->arrConfig[strtolower($str)]; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | return; |
@@ -489,9 +489,9 @@ discard block |
||
| 489 | 489 | * |
| 490 | 490 | * @return string |
| 491 | 491 | */ |
| 492 | - public static function convertTypeToPHP ( $type ) |
|
| 492 | + public static function convertTypeToPHP($type) |
|
| 493 | 493 | { |
| 494 | - return self::$dataTypesDefault[ $type ]; |
|
| 494 | + return self::$dataTypesDefault[$type]; |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
@@ -499,8 +499,8 @@ discard block |
||
| 499 | 499 | * |
| 500 | 500 | * @return string |
| 501 | 501 | */ |
| 502 | - public function convertTypeToTypeFramework ( $type ) |
|
| 502 | + public function convertTypeToTypeFramework($type) |
|
| 503 | 503 | { |
| 504 | - return $this->dataTypes[ $type ]; |
|
| 504 | + return $this->dataTypes[$type]; |
|
| 505 | 505 | } |
| 506 | 506 | } |