@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | * @var string |
23 | 23 | */ |
24 | 24 | protected $framework = "phalcon"; |
25 | - public $reservedWord = array ( 'public' => 'Main' ); |
|
25 | + public $reservedWord = array('public' => 'Main'); |
|
26 | 26 | |
27 | - protected $dataTypes = array ( |
|
27 | + protected $dataTypes = array( |
|
28 | 28 | 'int' => 'integer', |
29 | 29 | 'float' => 'decimal' |
30 | 30 | ); |
31 | 31 | |
32 | 32 | const SEPARETOR = "\\"; |
33 | 33 | |
34 | - protected function init () |
|
34 | + protected function init() |
|
35 | 35 | { |
36 | 36 | } |
37 | 37 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return array |
42 | 42 | */ |
43 | - protected function getParams () |
|
43 | + protected function getParams() |
|
44 | 44 | { |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | - protected function parseFrameworkConfig () |
|
48 | + protected function parseFrameworkConfig() |
|
49 | 49 | { |
50 | 50 | // TODO: Implement parseFrameworkConfig() method. |
51 | 51 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @inheritdoc |
55 | 55 | */ |
56 | - protected function getBaseNamespace () |
|
56 | + protected function getBaseNamespace() |
|
57 | 57 | { |
58 | - return array ( |
|
59 | - $this->arrConfig[ 'namespace' ], |
|
58 | + return array( |
|
59 | + $this->arrConfig['namespace'], |
|
60 | 60 | 'Models' |
61 | 61 | ); |
62 | 62 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
68 | 68 | */ |
69 | - public function getMakeFileInstances () |
|
69 | + public function getMakeFileInstances() |
|
70 | 70 | { |
71 | - return array ( |
|
72 | - Entity::getInstance (), |
|
73 | - Model::getInstance (), |
|
74 | - Peer::getInstance () |
|
71 | + return array( |
|
72 | + Entity::getInstance(), |
|
73 | + Model::getInstance(), |
|
74 | + Peer::getInstance() |
|
75 | 75 | ); |
76 | 76 | } |
77 | 77 |
@@ -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,11 +30,11 @@ 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 | - return array ( |
|
36 | - 'parents' => $this->listParents ( $makerFile , $dbTable ) , |
|
37 | - 'depends' => $this->listDependence ( $makerFile , $dbTable ) |
|
35 | + return array( |
|
36 | + 'parents' => $this->listParents($makerFile, $dbTable), |
|
37 | + 'depends' => $this->listDependence($makerFile, $dbTable) |
|
38 | 38 | ); |
39 | 39 | } |
40 | 40 | |
@@ -44,39 +44,39 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array |
46 | 46 | */ |
47 | - private function listParents ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
47 | + private function listParents(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
48 | 48 | { |
49 | - $parents = array (); |
|
50 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) |
|
49 | + $parents = array(); |
|
50 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
51 | 51 | { |
52 | - $constrant = $objColumn->getFks (); |
|
52 | + $constrant = $objColumn->getFks(); |
|
53 | 53 | $name = |
54 | 54 | 'Parent' |
55 | 55 | . ZendFrameworkOne::SEPARETOR |
56 | - . AbstractMaker::getClassName ( $constrant->getTable () ) |
|
56 | + . AbstractMaker::getClassName($constrant->getTable()) |
|
57 | 57 | . ZendFrameworkOne::SEPARETOR |
58 | 58 | . 'By' |
59 | 59 | . ZendFrameworkOne::SEPARETOR |
60 | - . $objColumn->getName (); |
|
60 | + . $objColumn->getName(); |
|
61 | 61 | |
62 | - $variable = $constrant->getNameConstrant () . ZendFrameworkOne::SEPARETOR . $objColumn->getName (); |
|
62 | + $variable = $constrant->getNameConstrant() . ZendFrameworkOne::SEPARETOR . $objColumn->getName(); |
|
63 | 63 | |
64 | - $arrClass = array ( |
|
65 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
66 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
64 | + $arrClass = array( |
|
65 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
66 | + AbstractMaker::getClassName($constrant->getTable()) |
|
67 | 67 | ); |
68 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
69 | - |
|
70 | - $parents[] = array ( |
|
71 | - 'class' => $class , |
|
72 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
73 | - 'table' => $constrant->getTable () , |
|
74 | - 'column' => $constrant->getColumn() , |
|
75 | - 'name' => $constrant->getNameConstrant() , |
|
68 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
69 | + |
|
70 | + $parents[] = array( |
|
71 | + 'class' => $class, |
|
72 | + 'function' => AbstractMaker::getClassName($name), |
|
73 | + 'table' => $constrant->getTable(), |
|
74 | + 'column' => $constrant->getColumn(), |
|
75 | + 'name' => $constrant->getNameConstrant(), |
|
76 | 76 | 'variable' => $variable |
77 | 77 | |
78 | 78 | ); |
79 | - unset( $name ); |
|
79 | + unset($name); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return $parents; |
@@ -88,43 +88,43 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return array |
90 | 90 | */ |
91 | - private function listDependence ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
91 | + private function listDependence(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
92 | 92 | { |
93 | - $depends = array (); |
|
94 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
93 | + $depends = array(); |
|
94 | + foreach ($dbTable->getDependences() as $objColumn) |
|
95 | 95 | { |
96 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
96 | + foreach ($objColumn->getDependences() as $dependence) |
|
97 | 97 | { |
98 | 98 | $name = |
99 | 99 | 'Depend' |
100 | 100 | . ZendFrameworkOne::SEPARETOR |
101 | - . AbstractMaker::getClassName ( $dependence->getTable () ) |
|
101 | + . AbstractMaker::getClassName($dependence->getTable()) |
|
102 | 102 | . ZendFrameworkOne::SEPARETOR |
103 | 103 | . 'By' |
104 | 104 | . ZendFrameworkOne::SEPARETOR |
105 | - . $objColumn->getName (); |
|
105 | + . $objColumn->getName(); |
|
106 | 106 | |
107 | - if ( ! key_exists ( $name , $this->validFunc ) ) |
|
107 | + if ( ! key_exists($name, $this->validFunc)) |
|
108 | 108 | { |
109 | - $variable = $dependence->getNameConstrant () . ZendFrameworkOne::SEPARETOR . $objColumn->getName (); |
|
109 | + $variable = $dependence->getNameConstrant() . ZendFrameworkOne::SEPARETOR . $objColumn->getName(); |
|
110 | 110 | |
111 | - $arrClass = array ( |
|
112 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
113 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
111 | + $arrClass = array( |
|
112 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
113 | + AbstractMaker::getClassName($dependence->getTable()) |
|
114 | 114 | ); |
115 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
115 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
116 | 116 | |
117 | - $this->validFunc[ $name ] = true; |
|
118 | - $depends[] = array ( |
|
117 | + $this->validFunc[$name] = true; |
|
118 | + $depends[] = array( |
|
119 | 119 | 'class' => $class, |
120 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
121 | - 'table' => $dependence->getTable () , |
|
122 | - 'column' => $dependence->getColumn () , |
|
123 | - 'name' => $dependence->getNameConstrant (), |
|
120 | + 'function' => AbstractMaker::getClassName($name), |
|
121 | + 'table' => $dependence->getTable(), |
|
122 | + 'column' => $dependence->getColumn(), |
|
123 | + 'name' => $dependence->getNameConstrant(), |
|
124 | 124 | 'variable' => $variable |
125 | 125 | ); |
126 | 126 | } |
127 | - unset( $name ); |
|
127 | + unset($name); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 |
@@ -28,68 +28,68 @@ |
||
28 | 28 | * |
29 | 29 | * @return array |
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 $objColumn ) |
|
36 | + $dependents = array(); |
|
37 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
38 | 38 | { |
39 | - $constrant = $objColumn->getFks (); |
|
40 | - $variable = $constrant->getNameConstrant () . ZendFrameworkOne::SEPARETOR . $objColumn->getName (); |
|
39 | + $constrant = $objColumn->getFks(); |
|
40 | + $variable = $constrant->getNameConstrant() . ZendFrameworkOne::SEPARETOR . $objColumn->getName(); |
|
41 | 41 | |
42 | - $arrClass = array ( |
|
43 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
42 | + $arrClass = array( |
|
43 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
44 | 44 | 'DbTable', |
45 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
45 | + AbstractMaker::getClassName($constrant->getTable()) |
|
46 | 46 | ); |
47 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
47 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
48 | 48 | |
49 | - $references[] = sprintf ( |
|
49 | + $references[] = sprintf( |
|
50 | 50 | " |
51 | 51 | '%s' => array ( |
52 | 52 | 'columns' => '%s' , |
53 | 53 | 'refTableClass' => '%s', |
54 | 54 | 'refColumns' =>'%s' |
55 | 55 | )", |
56 | - AbstractMaker::getClassName ( $variable ), |
|
57 | - $objColumn->getName (), |
|
56 | + AbstractMaker::getClassName($variable), |
|
57 | + $objColumn->getName(), |
|
58 | 58 | $class, |
59 | - $constrant->getColumn () |
|
59 | + $constrant->getColumn() |
|
60 | 60 | |
61 | 61 | ); |
62 | 62 | } |
63 | 63 | |
64 | - if ( sizeof ( $references ) > 0 ) |
|
64 | + if (sizeof($references) > 0) |
|
65 | 65 | { |
66 | 66 | $referenceMap = "protected \$_referenceMap = array(" . |
67 | - join ( ',', $references ) . "\n );"; |
|
67 | + join(',', $references) . "\n );"; |
|
68 | 68 | } |
69 | 69 | |
70 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
70 | + foreach ($dbTable->getDependences() as $objColumn) |
|
71 | 71 | { |
72 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
72 | + foreach ($objColumn->getDependences() as $dependence) |
|
73 | 73 | { |
74 | - $arrClass = array ( |
|
75 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
74 | + $arrClass = array( |
|
75 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
76 | 76 | 'DbTable', |
77 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
77 | + AbstractMaker::getClassName($dependence->getTable()) |
|
78 | 78 | ); |
79 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
79 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
80 | 80 | |
81 | 81 | $dependents[] = $class; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - if ( sizeof ( $dependents ) > 0 ) |
|
85 | + if (sizeof($dependents) > 0) |
|
86 | 86 | { |
87 | 87 | $dependentTables = "protected \$_dependentTables = array(\n '" . |
88 | - join ( "',\n '", $dependents ) . "'\n );"; |
|
88 | + join("',\n '", $dependents) . "'\n );"; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
92 | - return array ( |
|
92 | + return array( |
|
93 | 93 | 'referenceMap' => $referenceMap, |
94 | 94 | 'dependentTables' => $dependentTables |
95 | 95 | ); |
@@ -3,20 +3,20 @@ |
||
3 | 3 | /** |
4 | 4 | * Data Entity implementation for this class |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | - * @package <?=$objTables->getNamespace()."\n"?> |
|
9 | - * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>. <?="\n"?> |
|
8 | + * @package <?=$objTables->getNamespace() . "\n"?> |
|
9 | + * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>. <?="\n"?> |
|
10 | 10 | * |
11 | - * @author <?=$this->config->author."\n"?> |
|
11 | + * @author <?=$this->config->author . "\n"?> |
|
12 | 12 | * |
13 | - * @copyright <?=$this->config->copyright."\n"?> |
|
14 | - * @license <?=$this->config->license."\n"?> |
|
15 | - * @link <?=$this->config->link."\n"?> |
|
16 | - * @version <?=$this->config->version."\n"?> |
|
13 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
14 | + * @license <?=$this->config->license . "\n"?> |
|
15 | + * @link <?=$this->config->link . "\n"?> |
|
16 | + * @version <?=$this->config->version . "\n"?> |
|
17 | 17 | */ |
18 | 18 | |
19 | -class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ). "\n"?> |
|
19 | +class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n"?> |
|
20 | 20 | { |
21 | 21 | /* @TODO Codifique aqui */ |
22 | 22 | } |
@@ -359,8 +359,7 @@ |
||
359 | 359 | if ( is_null ( $this->_pdo ) ) { |
360 | 360 | if ( !empty( $this->socket ) ) { |
361 | 361 | $pdoString = $this->getPDOSocketString (); |
362 | - } |
|
363 | - else { |
|
362 | + } else { |
|
364 | 363 | $pdoString = $this->getPDOString (); |
365 | 364 | } |
366 | 365 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - private $argv = array (); |
|
55 | + private $argv = array(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private $adapterDriver; |
66 | 66 | |
67 | - private $frameworkList = array ( |
|
67 | + private $frameworkList = array( |
|
68 | 68 | 'none', |
69 | 69 | 'zf1', |
70 | 70 | 'phalcon' |
71 | 71 | ); |
72 | 72 | |
73 | - private $parameterList = array ( |
|
73 | + private $parameterList = array( |
|
74 | 74 | 'init' => 'Creates the necessary configuration file to start using the orm-generator.', |
75 | 75 | 'config-ini' => 'reference to another .ini file configuration (relative path).', |
76 | 76 | 'config-env' => 'orm-generator configuration environment.', |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | 'path' => "specify where to create the files (default is current directory).", |
86 | 86 | ); |
87 | 87 | |
88 | - public function __construct ( $argv, $basePath, $numArgs ) |
|
88 | + public function __construct($argv, $basePath, $numArgs) |
|
89 | 89 | { |
90 | - if ( array_key_exists ( 'help', $argv ) or ( $numArgs > 1 && count ( $argv ) < 1 ) ) { |
|
91 | - die ( $this->getUsage () ); |
|
90 | + if (array_key_exists('help', $argv) or ($numArgs > 1 && count($argv) < 1)) { |
|
91 | + die ($this->getUsage()); |
|
92 | 92 | } |
93 | - if ( array_key_exists ( 'version', $argv ) ) { |
|
94 | - die ( $this->getVersion () ); |
|
93 | + if (array_key_exists('version', $argv)) { |
|
94 | + die ($this->getVersion()); |
|
95 | 95 | } |
96 | - if ( array_key_exists ( 'status', $argv ) ) { |
|
97 | - $argv[ 'status' ] = true; |
|
96 | + if (array_key_exists('status', $argv)) { |
|
97 | + $argv['status'] = true; |
|
98 | 98 | } |
99 | 99 | |
100 | - $this->argv = $this->parseConfig ( $basePath, $argv ); |
|
100 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - public function getUsage () |
|
108 | + public function getUsage() |
|
109 | 109 | { |
110 | - $version = $this->getVersion (); |
|
111 | - $list = $this->renderParam (); |
|
110 | + $version = $this->getVersion(); |
|
111 | + $list = $this->renderParam(); |
|
112 | 112 | |
113 | 113 | return <<<EOF |
114 | 114 | parameters: |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | EOF; |
120 | 120 | } |
121 | 121 | |
122 | - public function renderParam () |
|
122 | + public function renderParam() |
|
123 | 123 | { |
124 | 124 | $return = ""; |
125 | - foreach ( $this->parameterList as $param => $desc ) { |
|
126 | - if ( strlen ( $param ) < 5 ) { |
|
125 | + foreach ($this->parameterList as $param => $desc) { |
|
126 | + if (strlen($param) < 5) { |
|
127 | 127 | $return .= "\t--" . $param . "\t\t: " . $desc . "\n"; |
128 | 128 | } |
129 | 129 | else { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | return $return; |
136 | 136 | } |
137 | 137 | |
138 | - public function getVersion () |
|
138 | + public function getVersion() |
|
139 | 139 | { |
140 | 140 | $version = static::$version; |
141 | 141 | |
@@ -151,26 +151,26 @@ discard block |
||
151 | 151 | * @return array |
152 | 152 | * @throws \Exception |
153 | 153 | */ |
154 | - private function parseConfig ( $basePath, $argv ) |
|
154 | + private function parseConfig($basePath, $argv) |
|
155 | 155 | { |
156 | - $this->_basePath = dirname ( $basePath . '/' ); |
|
156 | + $this->_basePath = dirname($basePath . '/'); |
|
157 | 157 | |
158 | - $configIni = isset( $argv[ 'config-ini' ] ) |
|
159 | - ? $argv[ 'config-ini' ] : $this->configIniDefault; |
|
158 | + $configIni = isset($argv['config-ini']) |
|
159 | + ? $argv['config-ini'] : $this->configIniDefault; |
|
160 | 160 | |
161 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
162 | - $configCurrent = self::parseConfigEnv ( $configTemp, $argv ); |
|
161 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
162 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
163 | 163 | |
164 | - if ( !isset( $configCurrent[ 'framework' ] ) ) { |
|
165 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
164 | + if ( ! isset($configCurrent['framework'])) { |
|
165 | + throw new \Exception("configure which framework you want to use! \n"); |
|
166 | 166 | } |
167 | 167 | |
168 | - if ( !in_array ( $configCurrent[ 'framework' ], $this->frameworkList ) ) { |
|
169 | - $frameworks = implode ( "\n\t", $this->frameworkList ); |
|
170 | - throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks . "\n\033[0m" ); |
|
168 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) { |
|
169 | + $frameworks = implode("\n\t", $this->frameworkList); |
|
170 | + throw new \Exception("list of frameworks: \n\t\033[1;33m" . $frameworks . "\n\033[0m"); |
|
171 | 171 | } |
172 | 172 | |
173 | - return $argv + array_filter ( $configCurrent ); |
|
173 | + return $argv + array_filter($configCurrent); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -180,20 +180,20 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string |
182 | 182 | */ |
183 | - private static function parseConfigEnv ( $configTemp, $argv ) |
|
183 | + private static function parseConfigEnv($configTemp, $argv) |
|
184 | 184 | { |
185 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) ? $configTemp[ key ( |
|
185 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) ? $configTemp[key( |
|
186 | 186 | $configTemp |
187 | - ) ][ 'config-env' ] : null; |
|
187 | + )]['config-env'] : null; |
|
188 | 188 | |
189 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] : $thisSection; |
|
189 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] : $thisSection; |
|
190 | 190 | |
191 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) { |
|
191 | + if (isset($configTemp[$thisSection]['extends'])) { |
|
192 | 192 | #faz marge da config principal com a config extendida |
193 | - return $configTemp[ $thisSection ] + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
193 | + return $configTemp[$thisSection] + $configTemp[$configTemp[$thisSection]['extends']]; |
|
194 | 194 | } |
195 | 195 | |
196 | - return $configTemp[ key ( $configTemp ) ]; |
|
196 | + return $configTemp[key($configTemp)]; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -207,29 +207,29 @@ discard block |
||
207 | 207 | * @throws \Exception |
208 | 208 | * @return array |
209 | 209 | */ |
210 | - protected function loadIniFile ( $filename ) |
|
210 | + protected function loadIniFile($filename) |
|
211 | 211 | { |
212 | - if ( !is_file ( $filename ) ) { |
|
213 | - throw new \Exception( "configuration file does not exist! \n" ); |
|
212 | + if ( ! is_file($filename)) { |
|
213 | + throw new \Exception("configuration file does not exist! \n"); |
|
214 | 214 | } |
215 | 215 | |
216 | - $loaded = parse_ini_file ( $filename, true ); |
|
217 | - $iniArray = array (); |
|
218 | - foreach ( $loaded as $key => $data ) { |
|
219 | - $pieces = explode ( $this->sectionSeparator, $key ); |
|
220 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
221 | - switch ( count ( $pieces ) ) { |
|
216 | + $loaded = parse_ini_file($filename, true); |
|
217 | + $iniArray = array(); |
|
218 | + foreach ($loaded as $key => $data) { |
|
219 | + $pieces = explode($this->sectionSeparator, $key); |
|
220 | + $thisSection = trim($pieces[0]); |
|
221 | + switch (count($pieces)) { |
|
222 | 222 | case 1: |
223 | - $iniArray[ $thisSection ] = $data; |
|
223 | + $iniArray[$thisSection] = $data; |
|
224 | 224 | break; |
225 | 225 | |
226 | 226 | case 2: |
227 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
228 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ), $data ); |
|
227 | + $extendedSection = trim($pieces[1]); |
|
228 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
229 | 229 | break; |
230 | 230 | |
231 | 231 | default: |
232 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
232 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
@@ -242,15 +242,15 @@ discard block |
||
242 | 242 | * @return \Classes\AdapterConfig\AbstractAdapter |
243 | 243 | * |
244 | 244 | */ |
245 | - private function factoryConfig () |
|
245 | + private function factoryConfig() |
|
246 | 246 | { |
247 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) { |
|
247 | + switch (strtolower($this->argv['framework'])) { |
|
248 | 248 | case 'zf1': |
249 | - return new ZendFrameworkOne( $this->argv ); |
|
249 | + return new ZendFrameworkOne($this->argv); |
|
250 | 250 | case 'phalcon': |
251 | - return new Phalcon( $this->argv ); |
|
251 | + return new Phalcon($this->argv); |
|
252 | 252 | default: |
253 | - return new None( $this->argv ); |
|
253 | + return new None($this->argv); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | } |
@@ -262,31 +262,31 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return AdaptersDriver\AbsractAdapter |
264 | 264 | */ |
265 | - private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
|
265 | + private function factoryDriver(AdapterConfig\AbstractAdapter $config) |
|
266 | 266 | { |
267 | - switch ( $this->argv[ 'driver' ] ) { |
|
267 | + switch ($this->argv['driver']) { |
|
268 | 268 | case 'pgsql': |
269 | 269 | case 'pdo_pgsql': |
270 | - return new Pgsql( $config ); |
|
270 | + return new Pgsql($config); |
|
271 | 271 | case 'mysql': |
272 | 272 | case 'pdo_mysql': |
273 | - return new Mysql( $config ); |
|
273 | + return new Mysql($config); |
|
274 | 274 | case 'mssql': |
275 | - return new Mssql( $config ); |
|
275 | + return new Mssql($config); |
|
276 | 276 | case 'dblib': |
277 | - return new Dblib( $config ); |
|
277 | + return new Dblib($config); |
|
278 | 278 | case 'sqlsrv': |
279 | - return new Sqlsrv( $config ); |
|
279 | + return new Sqlsrv($config); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | 284 | * @return AdapterConfig\AbstractAdapter |
285 | 285 | */ |
286 | - public function getAdapterConfig () |
|
286 | + public function getAdapterConfig() |
|
287 | 287 | { |
288 | - if ( !$this->adapterConfig instanceof AbstractAdapter ) { |
|
289 | - $this->adapterConfig = $this->factoryConfig (); |
|
288 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) { |
|
289 | + $this->adapterConfig = $this->factoryConfig(); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | return $this->adapterConfig; |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | /** |
296 | 296 | * @return AdaptersDriver\AbsractAdapter |
297 | 297 | */ |
298 | - public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
|
298 | + public function getAdapterDriver(AdapterConfig\AbstractAdapter $config) |
|
299 | 299 | { |
300 | - if ( !$this->adapterDriver ) { |
|
301 | - $this->adapterDriver = $this->factoryDriver ( $config ); |
|
300 | + if ( ! $this->adapterDriver) { |
|
301 | + $this->adapterDriver = $this->factoryDriver($config); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | return $this->adapterDriver; |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !ini_get ( 'short_open_tag' ) ) { |
|
4 | - die( "please enable short_open_tag directive in php.ini\n" ); |
|
3 | +if ( ! ini_get('short_open_tag')) { |
|
4 | + die("please enable short_open_tag directive in php.ini\n"); |
|
5 | 5 | } |
6 | 6 | |
7 | -if ( !ini_get ( 'register_argc_argv' ) ) { |
|
8 | - die( "please enable register_argc_argv directive in php.ini\n" ); |
|
7 | +if ( ! ini_get('register_argc_argv')) { |
|
8 | + die("please enable register_argc_argv directive in php.ini\n"); |
|
9 | 9 | } |
10 | 10 | |
11 | -if ( function_exists ( 'ini_set' ) ) { |
|
12 | - @ini_set ( 'display_errors', 1 ); |
|
11 | +if (function_exists('ini_set')) { |
|
12 | + @ini_set('display_errors', 1); |
|
13 | 13 | |
14 | - $memoryInBytes = function ( $value ) { |
|
15 | - $unit = strtolower ( substr ( $value, -1, 1 ) ); |
|
14 | + $memoryInBytes = function($value) { |
|
15 | + $unit = strtolower(substr($value, -1, 1)); |
|
16 | 16 | $value = (int) $value; |
17 | - switch ( $unit ) { |
|
17 | + switch ($unit) { |
|
18 | 18 | case 'g': |
19 | 19 | $value *= 1024; |
20 | 20 | // no break (cumulative multiplier) |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | return $value; |
29 | 29 | }; |
30 | 30 | |
31 | - $memoryLimit = trim ( ini_get ( 'memory_limit' ) ); |
|
31 | + $memoryLimit = trim(ini_get('memory_limit')); |
|
32 | 32 | // Increase memory_limit if it is lower than 1GB |
33 | - if ( $memoryLimit != -1 && $memoryInBytes( $memoryLimit ) < 1024 * 1024 * 1024 ) { |
|
34 | - @ini_set ( 'memory_limit', '1G' ); |
|
33 | + if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1024) { |
|
34 | + @ini_set('memory_limit', '1G'); |
|
35 | 35 | } |
36 | - unset( $memoryInBytes, $memoryLimit ); |
|
36 | + unset($memoryInBytes, $memoryLimit); |
|
37 | 37 | } |
38 | 38 | |
39 | -\Phar::interceptFileFuncs (); |
|
39 | +\Phar::interceptFileFuncs(); |
|
40 | 40 | |
41 | -set_include_path ( |
|
42 | - implode ( |
|
41 | +set_include_path( |
|
42 | + implode( |
|
43 | 43 | PATH_SEPARATOR, |
44 | - array ( |
|
45 | - realpath ( __DIR__ ), |
|
46 | - get_include_path (), |
|
44 | + array( |
|
45 | + realpath(__DIR__), |
|
46 | + get_include_path(), |
|
47 | 47 | ) |
48 | 48 | ) |
49 | 49 | ); |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | require_once 'Classes/MakerConfigFile.php'; |
54 | 54 | |
55 | 55 | try { |
56 | - $_path = realpath ( |
|
57 | - str_replace ( |
|
56 | + $_path = realpath( |
|
57 | + str_replace( |
|
58 | 58 | 'phar://', |
59 | 59 | '', |
60 | 60 | __DIR__ |
61 | 61 | ) |
62 | 62 | ); |
63 | 63 | |
64 | - $arrValid = array ( |
|
64 | + $arrValid = array( |
|
65 | 65 | 'version', |
66 | 66 | 'help', |
67 | 67 | 'status', |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | 'path:' |
77 | 77 | ); |
78 | 78 | |
79 | - $arg = getopt ( null, $arrValid ); |
|
80 | - if ( array_key_exists ( 'init', $arg ) ) { |
|
81 | - $maker = new \Classes\MakerConfigFile( $arg, $_path ); |
|
79 | + $arg = getopt(null, $arrValid); |
|
80 | + if (array_key_exists('init', $arg)) { |
|
81 | + $maker = new \Classes\MakerConfigFile($arg, $_path); |
|
82 | 82 | } |
83 | 83 | else { |
84 | - $maker = new \Classes\MakerFile( new \Classes\Config( $arg, $_path, count ( $argv ) ) ); |
|
84 | + $maker = new \Classes\MakerFile(new \Classes\Config($arg, $_path, count($argv))); |
|
85 | 85 | } |
86 | 86 | |
87 | - $maker->run (); |
|
87 | + $maker->run(); |
|
88 | 88 | |
89 | -} catch ( \Exception $e ) { |
|
90 | - die( $e->getMessage () ); |
|
89 | +} catch (\Exception $e) { |
|
90 | + die($e->getMessage()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | __halt_compiler(); |
94 | 94 | \ No newline at end of file |
@@ -79,8 +79,7 @@ |
||
79 | 79 | $arg = getopt ( null, $arrValid ); |
80 | 80 | if ( array_key_exists ( 'init', $arg ) ) { |
81 | 81 | $maker = new \Classes\MakerConfigFile( $arg, $_path ); |
82 | - } |
|
83 | - else { |
|
82 | + } else { |
|
84 | 83 | $maker = new \Classes\MakerFile( new \Classes\Config( $arg, $_path, count ( $argv ) ) ); |
85 | 84 | } |
86 | 85 |
@@ -6,26 +6,26 @@ discard block |
||
6 | 6 | * @author Pedro Alarcao <[email protected]> |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! ini_get ( 'short_open_tag' ) ) |
|
9 | +if ( ! ini_get('short_open_tag')) |
|
10 | 10 | { |
11 | - die( "please enable short_open_tag directive in php.ini\n" ); |
|
11 | + die("please enable short_open_tag directive in php.ini\n"); |
|
12 | 12 | } |
13 | 13 | |
14 | -if ( ! ini_get ( 'register_argc_argv' ) ) |
|
14 | +if ( ! ini_get('register_argc_argv')) |
|
15 | 15 | { |
16 | - die( "please enable register_argc_argv directive in php.ini\n" ); |
|
16 | + die("please enable register_argc_argv directive in php.ini\n"); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | |
20 | -if ( function_exists ( 'ini_set' ) ) |
|
20 | +if (function_exists('ini_set')) |
|
21 | 21 | { |
22 | - @ini_set ( 'display_errors' , 1 ); |
|
22 | + @ini_set('display_errors', 1); |
|
23 | 23 | |
24 | - $memoryInBytes = function ( $value ) |
|
24 | + $memoryInBytes = function($value) |
|
25 | 25 | { |
26 | - $unit = strtolower ( substr ( $value , - 1 , 1 ) ); |
|
26 | + $unit = strtolower(substr($value, - 1, 1)); |
|
27 | 27 | $value = (int) $value; |
28 | - switch ( $unit ) |
|
28 | + switch ($unit) |
|
29 | 29 | { |
30 | 30 | case 'g': |
31 | 31 | $value *= 1024; |
@@ -40,21 +40,21 @@ discard block |
||
40 | 40 | return $value; |
41 | 41 | }; |
42 | 42 | |
43 | - $memoryLimit = trim ( ini_get ( 'memory_limit' ) ); |
|
43 | + $memoryLimit = trim(ini_get('memory_limit')); |
|
44 | 44 | // Increase memory_limit if it is lower than 1GB |
45 | - if ( $memoryLimit != - 1 && $memoryInBytes( $memoryLimit ) < 1024 * 1024 * 1024 ) |
|
45 | + if ($memoryLimit != - 1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1024) |
|
46 | 46 | { |
47 | - @ini_set ( 'memory_limit' , '1G' ); |
|
47 | + @ini_set('memory_limit', '1G'); |
|
48 | 48 | } |
49 | - unset( $memoryInBytes , $memoryLimit ); |
|
49 | + unset($memoryInBytes, $memoryLimit); |
|
50 | 50 | } |
51 | 51 | |
52 | -set_include_path ( |
|
53 | - implode ( |
|
54 | - PATH_SEPARATOR , |
|
55 | - array ( |
|
56 | - realpath ( dirname ( __FILE__ ) . "/build/" ) , |
|
57 | - get_include_path () , |
|
52 | +set_include_path( |
|
53 | + implode( |
|
54 | + PATH_SEPARATOR, |
|
55 | + array( |
|
56 | + realpath(dirname(__FILE__) . "/build/"), |
|
57 | + get_include_path(), |
|
58 | 58 | ) |
59 | 59 | ) |
60 | 60 | ); |
@@ -65,34 +65,34 @@ discard block |
||
65 | 65 | |
66 | 66 | try |
67 | 67 | { |
68 | - $arrValid = array ( |
|
69 | - 'version' , |
|
70 | - 'help' , |
|
71 | - 'status' , |
|
72 | - 'init' , |
|
73 | - 'config-env:' , |
|
74 | - 'config-ini:' , |
|
75 | - 'database:' , |
|
76 | - 'schema:' , |
|
77 | - 'driver:' , |
|
68 | + $arrValid = array( |
|
69 | + 'version', |
|
70 | + 'help', |
|
71 | + 'status', |
|
72 | + 'init', |
|
73 | + 'config-env:', |
|
74 | + 'config-ini:', |
|
75 | + 'database:', |
|
76 | + 'schema:', |
|
77 | + 'driver:', |
|
78 | 78 | 'tables:', |
79 | - 'framework:' , |
|
79 | + 'framework:', |
|
80 | 80 | 'path:' |
81 | 81 | ); |
82 | 82 | |
83 | - $_path = realpath ( __FILE__ ); |
|
84 | - $arg = getopt ( null , $arrValid ); |
|
85 | - if ( array_key_exists ( 'init' , $arg ) ) |
|
83 | + $_path = realpath(__FILE__); |
|
84 | + $arg = getopt(null, $arrValid); |
|
85 | + if (array_key_exists('init', $arg)) |
|
86 | 86 | { |
87 | - $maker = new \Classes\MakerConfigFile( $arg , $_path ); |
|
87 | + $maker = new \Classes\MakerConfigFile($arg, $_path); |
|
88 | 88 | } else |
89 | 89 | { |
90 | - $maker = new \Classes\MakerFile( new \Classes\Config( $arg , $_path, count($argv) ) ); |
|
90 | + $maker = new \Classes\MakerFile(new \Classes\Config($arg, $_path, count($argv))); |
|
91 | 91 | } |
92 | 92 | |
93 | - $maker->run (); |
|
93 | + $maker->run(); |
|
94 | 94 | |
95 | -} catch ( \Exception $e ) |
|
95 | +} catch (\Exception $e) |
|
96 | 96 | { |
97 | - die( $e->getMessage () ); |
|
97 | + die($e->getMessage()); |
|
98 | 98 | } |