@@ -79,7 +79,7 @@ |
||
79 | 79 | { |
80 | 80 | $length = $this->getProgress (); |
81 | 81 | printf ( "\r[%-100s] %d%%" , str_repeat ( "=" , $length ) |
82 | - . ">" , $length ); |
|
82 | + . ">" , $length ); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | |
15 | 15 | private $progresslength = 0; |
16 | 16 | |
17 | - private function __construct (){ } |
|
17 | + private function __construct() { } |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @return \Classes\Update\ProgressBar |
21 | 21 | */ |
22 | - public static function getInstance () |
|
22 | + public static function getInstance() |
|
23 | 23 | { |
24 | - if ( is_null ( self::$progressBar ) ) |
|
24 | + if (is_null(self::$progressBar)) |
|
25 | 25 | { |
26 | 26 | self::$progressBar = new ProgressBar(); |
27 | 27 | } |
@@ -29,38 +29,38 @@ discard block |
||
29 | 29 | return self::$progressBar; |
30 | 30 | } |
31 | 31 | |
32 | - public function setMaxByte ( $bytesMax ) |
|
32 | + public function setMaxByte($bytesMax) |
|
33 | 33 | { |
34 | 34 | $this->max = $bytesMax; |
35 | 35 | |
36 | 36 | return $this; |
37 | 37 | } |
38 | 38 | |
39 | - public function setProgress ( $progress ) |
|
39 | + public function setProgress($progress) |
|
40 | 40 | { |
41 | 41 | $this->progress = $progress; |
42 | - $this->calcule (); |
|
42 | + $this->calcule(); |
|
43 | 43 | |
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 | |
47 | - public function getProgress () |
|
47 | + public function getProgress() |
|
48 | 48 | { |
49 | 49 | return $this->progresslength; |
50 | 50 | } |
51 | 51 | |
52 | - public function calcule () |
|
52 | + public function calcule() |
|
53 | 53 | { |
54 | - if ( $this->progress > 0 ) |
|
54 | + if ($this->progress > 0) |
|
55 | 55 | { |
56 | - $this->progresslength = round( $this->progress * 100 / $this->max ); |
|
56 | + $this->progresslength = round($this->progress * 100 / $this->max); |
|
57 | 57 | //$this->progresslength = (int) ( ( $this->progress / $this->max ) * 100 ); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - public function finish () |
|
61 | + public function finish() |
|
62 | 62 | { |
63 | - if ( $this->getProgress () >= 99 && !self::$finished) |
|
63 | + if ($this->getProgress() >= 99 && ! self::$finished) |
|
64 | 64 | { |
65 | 65 | echo "\n\033[1;32mDone!\033[0m\n"; |
66 | 66 | self::$finished = 1; |
@@ -68,25 +68,25 @@ discard block |
||
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | - public function render () |
|
71 | + public function render() |
|
72 | 72 | { |
73 | - if ( $this->progress > 0 && !self::$finished) |
|
73 | + if ($this->progress > 0 && ! self::$finished) |
|
74 | 74 | { |
75 | - if ( ! isset( $this->max ) ) |
|
75 | + if ( ! isset($this->max)) |
|
76 | 76 | { |
77 | - printf ( "\rUnknown filesize.. %2d kb done.." , $this->progress / 1024 ); |
|
77 | + printf("\rUnknown filesize.. %2d kb done..", $this->progress / 1024); |
|
78 | 78 | } else |
79 | 79 | { |
80 | - $length = $this->getProgress (); |
|
81 | - printf ( "\r[%-100s] %d%%" , str_repeat ( "=" , $length ) |
|
82 | - . ">" , $length ); |
|
80 | + $length = $this->getProgress(); |
|
81 | + printf("\r[%-100s] %d%%", str_repeat("=", $length) |
|
82 | + . ">", $length); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this; |
87 | 87 | } |
88 | 88 | |
89 | - public function clear () |
|
89 | + public function clear() |
|
90 | 90 | { |
91 | 91 | $this->max = 0; |
92 | 92 | $this->progress = 0; |
@@ -13,28 +13,28 @@ discard block |
||
13 | 13 | class GitHub extends AbstractContent |
14 | 14 | { |
15 | 15 | private static $tagsGithub = "https://api.github.com/repos/pedro151/orm-generator/tags"; |
16 | - private static $listVersion = array (); |
|
16 | + private static $listVersion = array(); |
|
17 | 17 | private $phar = "https://raw.githubusercontent.com/pedro151/orm-generator/%s/bin/orm-generator.phar"; |
18 | 18 | //private $phar = "https://github.com/pedro151/orm-generator/blob/%s/bin/orm-generator.phar?raw=true"; |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @return mixed |
22 | 22 | */ |
23 | - public function getInfo () |
|
23 | + public function getInfo() |
|
24 | 24 | { |
25 | - return json_decode ( $this->getContent ( self::$tagsGithub ) ); |
|
25 | + return json_decode($this->getContent(self::$tagsGithub)); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * |
30 | 30 | */ |
31 | - protected function init () |
|
31 | + protected function init() |
|
32 | 32 | { |
33 | - if ( is_array ( $this->getInfo () ) ) |
|
33 | + if (is_array($this->getInfo())) |
|
34 | 34 | { |
35 | - foreach ( $this->getInfo () as $index => $objTag ) |
|
35 | + foreach ($this->getInfo() as $index => $objTag) |
|
36 | 36 | { |
37 | - self::$listVersion[ preg_replace ( "/[^0-9.]/" , "" , $objTag->name ) ] = sprintf ( $this->phar , $objTag->name ); |
|
37 | + self::$listVersion[preg_replace("/[^0-9.]/", "", $objTag->name)] = sprintf($this->phar, $objTag->name); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function getLastVersion () |
|
45 | + public function getLastVersion() |
|
46 | 46 | { |
47 | - return current ( array_keys ( self::$listVersion ) ); |
|
47 | + return current(array_keys(self::$listVersion)); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @return mixed |
52 | 52 | */ |
53 | - public function getLastPhar () |
|
53 | + public function getLastPhar() |
|
54 | 54 | { |
55 | - reset ( self::$listVersion ); |
|
55 | + reset(self::$listVersion); |
|
56 | 56 | |
57 | - return current ( self::$listVersion ); |
|
57 | + return current(self::$listVersion); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | - public function getPharByVersion ( $version ) |
|
65 | + public function getPharByVersion($version) |
|
66 | 66 | { |
67 | - return self::$listVersion[ $version ]; |
|
67 | + return self::$listVersion[$version]; |
|
68 | 68 | } |
69 | 69 | |
70 | - public function hasPharByVersion ( $version ) |
|
70 | + public function hasPharByVersion($version) |
|
71 | 71 | { |
72 | - return isset( self::$listVersion[ $version ] ); |
|
72 | + return isset(self::$listVersion[$version]); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -38,7 +38,7 @@ |
||
38 | 38 | if ( self::HasNewVersion () ) |
39 | 39 | { |
40 | 40 | return "\033[0;31mThere is a new version " . self::$lastVersion |
41 | - . " available\033[0m \n"; |
|
41 | + . " available\033[0m \n"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - public static function getVersion () |
|
18 | + public static function getVersion() |
|
19 | 19 | { |
20 | 20 | return static::$_currentVersion; |
21 | 21 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @return bool |
25 | 25 | */ |
26 | - public static function HasNewVersion () |
|
26 | + public static function HasNewVersion() |
|
27 | 27 | { |
28 | - self::$lastVersion = GitHub::getInstance ()->getLastVersion (); |
|
28 | + self::$lastVersion = GitHub::getInstance()->getLastVersion(); |
|
29 | 29 | |
30 | 30 | return self::$lastVersion > static::$_currentVersion; |
31 | 31 | } |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - public function messageHasNewVersion () |
|
36 | + public function messageHasNewVersion() |
|
37 | 37 | { |
38 | - if ( self::HasNewVersion () ) |
|
38 | + if (self::HasNewVersion()) |
|
39 | 39 | { |
40 | 40 | return "\033[0;31mThere is a new version " . self::$lastVersion |
41 | 41 | . " available\033[0m \n"; |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return bool |
49 | 49 | */ |
50 | - public static function equalVersion ( $version ) |
|
50 | + public static function equalVersion($version) |
|
51 | 51 | { |
52 | - return $version === self::getVersion (); |
|
52 | + return $version === self::getVersion(); |
|
53 | 53 | } |
54 | 54 | |
55 | - public static function existVersion ( $version ) |
|
55 | + public static function existVersion($version) |
|
56 | 56 | { |
57 | - return GitHub::getInstance ()->hasPharByVersion ( $version ); |
|
57 | + return GitHub::getInstance()->hasPharByVersion($version); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | foreach ( $arrFoldersName as $index => $folderName ) |
101 | 101 | { |
102 | 102 | $arrFoldersName[ $index ] = $this->getConfig () |
103 | - ->replaceReservedWord ( $folderName ); |
|
103 | + ->replaceReservedWord ( $folderName ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | return implode ( DIRECTORY_SEPARATOR , array_filter ( $arrFoldersName ) ); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $folderName , |
158 | 158 | $this->getClassName ( |
159 | 159 | $this->getConfig () |
160 | - ->getDatabase () |
|
160 | + ->getDatabase () |
|
161 | 161 | ) |
162 | 162 | ); |
163 | 163 | $this->location = array ( $this->filterLocation ( $url ) ); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @type string[] |
24 | 24 | */ |
25 | - public $location = array (); |
|
25 | + public $location = array(); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * caminho de pastas Base |
@@ -46,46 +46,46 @@ discard block |
||
46 | 46 | |
47 | 47 | private $msgReservedWord = "\033[0mPlease enter the value for reserved word \033[0;31m'%index%' \033[1;33m[%config%]:\033[0m "; |
48 | 48 | |
49 | - public function __construct ( Config $config ) |
|
49 | + public function __construct(Config $config) |
|
50 | 50 | { |
51 | - $this->config = $config->getAdapterConfig (); |
|
52 | - $this->parseReservedWord ( $this->getConfig () ); |
|
53 | - $this->driver = $config->getAdapterDriver ( $this->getConfig () ); |
|
54 | - $this->parseLocation ( $config->_basePath ); |
|
51 | + $this->config = $config->getAdapterConfig(); |
|
52 | + $this->parseReservedWord($this->getConfig()); |
|
53 | + $this->driver = $config->getAdapterDriver($this->getConfig()); |
|
54 | + $this->parseLocation($config->_basePath); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @param AdapterConfig\AbstractAdapter $config |
59 | 59 | */ |
60 | - public function parseReservedWord ( AdapterConfig\AbstractAdapter $config ) |
|
60 | + public function parseReservedWord(AdapterConfig\AbstractAdapter $config) |
|
61 | 61 | { |
62 | 62 | $palavrasReservadas = $config->reservedWord; |
63 | - if ( ! $palavrasReservadas ) |
|
63 | + if ( ! $palavrasReservadas) |
|
64 | 64 | { |
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | - $schema = $config->getSchemas (); |
|
69 | - $db = $config->getDatabase (); |
|
70 | - $hasSchema = array_intersect ( $schema , array_flip ( $palavrasReservadas ) ); |
|
71 | - $hasDatabase = in_array ( $db , $palavrasReservadas ); |
|
72 | - if ( ! ( $hasSchema or $hasDatabase ) ) |
|
68 | + $schema = $config->getSchemas(); |
|
69 | + $db = $config->getDatabase(); |
|
70 | + $hasSchema = array_intersect($schema, array_flip($palavrasReservadas)); |
|
71 | + $hasDatabase = in_array($db, $palavrasReservadas); |
|
72 | + if ( ! ($hasSchema or $hasDatabase)) |
|
73 | 73 | { |
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | echo "- database has reserved words\n"; |
78 | - foreach ( $palavrasReservadas as $index => $config ) |
|
78 | + foreach ($palavrasReservadas as $index => $config) |
|
79 | 79 | { |
80 | - $attribs = array ( |
|
81 | - "%index%" => $index , |
|
80 | + $attribs = array( |
|
81 | + "%index%" => $index, |
|
82 | 82 | "%config%" => $config |
83 | 83 | ); |
84 | - echo strtr ( $this->msgReservedWord , $attribs ); |
|
85 | - $line = trim ( fgets ( STDIN ) ); |
|
86 | - if ( ! empty( $line ) ) |
|
84 | + echo strtr($this->msgReservedWord, $attribs); |
|
85 | + $line = trim(fgets(STDIN)); |
|
86 | + if ( ! empty($line)) |
|
87 | 87 | { |
88 | - $this->getConfig ()->reservedWord[ $index ] = $line; |
|
88 | + $this->getConfig()->reservedWord[$index] = $line; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -95,199 +95,199 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return string |
97 | 97 | */ |
98 | - private function filterLocation ( $arrFoldersName ) |
|
98 | + private function filterLocation($arrFoldersName) |
|
99 | 99 | { |
100 | - foreach ( $arrFoldersName as $index => $folderName ) |
|
100 | + foreach ($arrFoldersName as $index => $folderName) |
|
101 | 101 | { |
102 | - $arrFoldersName[ $index ] = $this->getConfig () |
|
103 | - ->replaceReservedWord ( $folderName ); |
|
102 | + $arrFoldersName[$index] = $this->getConfig() |
|
103 | + ->replaceReservedWord($folderName); |
|
104 | 104 | } |
105 | 105 | |
106 | - return implode ( DIRECTORY_SEPARATOR , array_filter ( $arrFoldersName ) ); |
|
106 | + return implode(DIRECTORY_SEPARATOR, array_filter($arrFoldersName)); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Analisa os caminhos das pastas base |
111 | 111 | */ |
112 | - public function parseLocation ( $basePath ) |
|
112 | + public function parseLocation($basePath) |
|
113 | 113 | { |
114 | 114 | |
115 | - $arrBase = array ( |
|
116 | - $basePath , |
|
115 | + $arrBase = array( |
|
116 | + $basePath, |
|
117 | 117 | $this->config->path |
118 | 118 | ); |
119 | 119 | |
120 | - $this->baseLocation = $this->filterLocation ( $arrBase ); |
|
120 | + $this->baseLocation = $this->filterLocation($arrBase); |
|
121 | 121 | |
122 | 122 | # pasta com nome do driver do banco |
123 | 123 | $driverBase = ''; |
124 | - if ( (bool) @$this->config->{"folder-database"} ) |
|
124 | + if ((bool) @$this->config->{"folder-database"} ) |
|
125 | 125 | { |
126 | - $classDriver = explode ( '\\' , get_class ( $this->driver ) ); |
|
127 | - $driverBase = end ( $classDriver ); |
|
126 | + $classDriver = explode('\\', get_class($this->driver)); |
|
127 | + $driverBase = end($classDriver); |
|
128 | 128 | } |
129 | 129 | $folderName = ''; |
130 | - if ( (bool) @$this->config->{"folder-name"} ) |
|
130 | + if ((bool) @$this->config->{"folder-name"} ) |
|
131 | 131 | { |
132 | - $folderName = $this->getClassName ( trim ( $this->config->{"folder-name"} ) ); |
|
132 | + $folderName = $this->getClassName(trim($this->config->{"folder-name"} )); |
|
133 | 133 | } |
134 | 134 | |
135 | - if ( $this->config->hasSchemas () ) |
|
135 | + if ($this->config->hasSchemas()) |
|
136 | 136 | { |
137 | 137 | |
138 | - $schemas = $this->config->getSchemas (); |
|
139 | - foreach ( $schemas as $schema ) |
|
138 | + $schemas = $this->config->getSchemas(); |
|
139 | + foreach ($schemas as $schema) |
|
140 | 140 | { |
141 | - $arrUrl = array ( |
|
142 | - $this->baseLocation , |
|
143 | - $driverBase , |
|
144 | - $folderName , |
|
145 | - $this->getClassName ( $schema ) |
|
141 | + $arrUrl = array( |
|
142 | + $this->baseLocation, |
|
143 | + $driverBase, |
|
144 | + $folderName, |
|
145 | + $this->getClassName($schema) |
|
146 | 146 | ); |
147 | 147 | |
148 | - $this->location[ $schema ] = $this->filterLocation ( $arrUrl ); |
|
149 | - unset( $arrUrl ); |
|
148 | + $this->location[$schema] = $this->filterLocation($arrUrl); |
|
149 | + unset($arrUrl); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } else |
153 | 153 | { |
154 | - $url = array ( |
|
155 | - $this->baseLocation , |
|
156 | - $driverBase , |
|
157 | - $folderName , |
|
158 | - $this->getClassName ( |
|
159 | - $this->getConfig () |
|
160 | - ->getDatabase () |
|
154 | + $url = array( |
|
155 | + $this->baseLocation, |
|
156 | + $driverBase, |
|
157 | + $folderName, |
|
158 | + $this->getClassName( |
|
159 | + $this->getConfig() |
|
160 | + ->getDatabase() |
|
161 | 161 | ) |
162 | 162 | ); |
163 | - $this->location = array ( $this->filterLocation ( $url ) ); |
|
164 | - unset( $url ); |
|
163 | + $this->location = array($this->filterLocation($url)); |
|
164 | + unset($url); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * @return AdapterConfig\AbstractAdapter |
170 | 170 | */ |
171 | - public function getConfig () |
|
171 | + public function getConfig() |
|
172 | 172 | { |
173 | 173 | return $this->config; |
174 | 174 | } |
175 | 175 | |
176 | 176 | /* Get current time */ |
177 | - public function startTime () |
|
177 | + public function startTime() |
|
178 | 178 | { |
179 | 179 | echo "\033[1;32mStarting..\033[0m\n"; |
180 | - $this->startTime = microtime ( true ); |
|
180 | + $this->startTime = microtime(true); |
|
181 | 181 | } |
182 | 182 | |
183 | - private function getRunTime () |
|
183 | + private function getRunTime() |
|
184 | 184 | { |
185 | - return round ( ( microtime ( true ) - $this->startTime ) , 3 ); |
|
185 | + return round((microtime(true) - $this->startTime), 3); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | 189 | * @param $objMakeFile |
190 | 190 | */ |
191 | - private function generateFilesFixed ( FilesFixeds $objFilesFixeds ) |
|
191 | + private function generateFilesFixed(FilesFixeds $objFilesFixeds) |
|
192 | 192 | { |
193 | - if ( $objFilesFixeds->hasData () ) |
|
193 | + if ($objFilesFixeds->hasData()) |
|
194 | 194 | { |
195 | 195 | $file = $this->baseLocation |
196 | 196 | . DIRECTORY_SEPARATOR |
197 | - . $objFilesFixeds->getFileName () |
|
197 | + . $objFilesFixeds->getFileName() |
|
198 | 198 | . '.php'; |
199 | 199 | |
200 | - $tpl = $this->getParsedTplContents ( $objFilesFixeds->getTpl () ); |
|
201 | - self::makeSourcer ( $file , $tpl , true ); |
|
200 | + $tpl = $this->getParsedTplContents($objFilesFixeds->getTpl()); |
|
201 | + self::makeSourcer($file, $tpl, true); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | 206 | * Executa o Make, criando arquivos e Diretorios |
207 | 207 | */ |
208 | - public function run () |
|
208 | + public function run() |
|
209 | 209 | { |
210 | 210 | $cur = 0; |
211 | 211 | $numFilesCreated = 0; |
212 | 212 | $numFilesIgnored = 0; |
213 | 213 | |
214 | - $this->startTime (); |
|
215 | - $this->waitOfDatabase ( $cur ); |
|
214 | + $this->startTime(); |
|
215 | + $this->waitOfDatabase($cur); |
|
216 | 216 | |
217 | - $this->max = $this->driver->getTotalTables () * $this->countDiretory (); |
|
218 | - $progressBar = ProgressBar::getInstance ()->setMaxByte ( $this->max ); |
|
217 | + $this->max = $this->driver->getTotalTables() * $this->countDiretory(); |
|
218 | + $progressBar = ProgressBar::getInstance()->setMaxByte($this->max); |
|
219 | 219 | |
220 | - foreach ( $this->location as $schema => $location ) |
|
220 | + foreach ($this->location as $schema => $location) |
|
221 | 221 | { |
222 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) |
|
222 | + foreach ($this->factoryMakerFile() as $objMakeFile) |
|
223 | 223 | { |
224 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
225 | - if ( $this->config->isCleanTrash () ) |
|
224 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
225 | + if ($this->config->isCleanTrash()) |
|
226 | 226 | { |
227 | - CleanTrash::getInstance ()->run ( $path , $this->driver , $schema ); |
|
227 | + CleanTrash::getInstance()->run($path, $this->driver, $schema); |
|
228 | 228 | } |
229 | - self::makeDir ( $path ); |
|
229 | + self::makeDir($path); |
|
230 | 230 | |
231 | 231 | #Cria as Classes de Exceção e Abstratas |
232 | - foreach ( $objMakeFile->getListFilesFixed () as $nameObject ) |
|
232 | + foreach ($objMakeFile->getListFilesFixed() as $nameObject) |
|
233 | 233 | { |
234 | - $this->generateFilesFixed ( $objMakeFile->getFilesFixeds ( $nameObject ) ); |
|
234 | + $this->generateFilesFixed($objMakeFile->getFilesFixeds($nameObject)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | #Cria as Classes do Banco |
238 | - foreach ( $this->driver->getTables ( $schema ) as $key => $objTables ) |
|
238 | + foreach ($this->driver->getTables($schema) as $key => $objTables) |
|
239 | 239 | { |
240 | 240 | $file = $path . DIRECTORY_SEPARATOR |
241 | - . self::getClassName ( $objTables->getName () ) . '.php'; |
|
241 | + . self::getClassName($objTables->getName()) . '.php'; |
|
242 | 242 | |
243 | - $tpl = $this->getParsedTplContents ( |
|
244 | - $objMakeFile->getFileTpl () , |
|
245 | - $objMakeFile->parseRelation ( $this , $objTables ) , |
|
246 | - $objTables , |
|
243 | + $tpl = $this->getParsedTplContents( |
|
244 | + $objMakeFile->getFileTpl(), |
|
245 | + $objMakeFile->parseRelation($this, $objTables), |
|
246 | + $objTables, |
|
247 | 247 | $objMakeFile |
248 | 248 | |
249 | 249 | ); |
250 | - if ( self::makeSourcer ( $file , $tpl , $objMakeFile->isOverwrite () ) ) |
|
250 | + if (self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite())) |
|
251 | 251 | { |
252 | - ++ $numFilesCreated; |
|
252 | + ++$numFilesCreated; |
|
253 | 253 | } else |
254 | 254 | { |
255 | - ++ $numFilesIgnored; |
|
255 | + ++$numFilesIgnored; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | ++$cur; |
259 | - $progressBar->setProgress ( $cur )->render(); |
|
259 | + $progressBar->setProgress($cur)->render(); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - $this->reportProcess ( $numFilesCreated , $numFilesIgnored ); |
|
264 | + $this->reportProcess($numFilesCreated, $numFilesIgnored); |
|
265 | 265 | $progressBar->finish(); |
266 | 266 | } |
267 | 267 | |
268 | - private function waitOfDatabase ( &$cur ) |
|
268 | + private function waitOfDatabase(&$cur) |
|
269 | 269 | { |
270 | - printf ( "\033[1;33mWait, the database is being analyzed..\033[0m\n" ); |
|
271 | - $this->driver->runDatabase (); |
|
270 | + printf("\033[1;33mWait, the database is being analyzed..\033[0m\n"); |
|
271 | + $this->driver->runDatabase(); |
|
272 | 272 | } |
273 | 273 | |
274 | - private function reportProcess ( $numFilesCreated = 0 , $numFilesIgnored = 0 ) |
|
274 | + private function reportProcess($numFilesCreated = 0, $numFilesIgnored = 0) |
|
275 | 275 | { |
276 | - if ( $this->config->isStatusEnabled () ) |
|
276 | + if ($this->config->isStatusEnabled()) |
|
277 | 277 | { |
278 | - $databases = count ( $this->location ); |
|
279 | - $countDir = $this->countDiretory (); |
|
280 | - $totalTable = $this->driver->getTotalTables (); |
|
278 | + $databases = count($this->location); |
|
279 | + $countDir = $this->countDiretory(); |
|
280 | + $totalTable = $this->driver->getTotalTables(); |
|
281 | 281 | $totalFiles = $numFilesIgnored + $numFilesCreated; |
282 | - $totalFilesDeleted = CleanTrash::getInstance ()->getNumFilesDeleted (); |
|
282 | + $totalFilesDeleted = CleanTrash::getInstance()->getNumFilesDeleted(); |
|
283 | 283 | echo "\n------"; |
284 | - printf ( "\n\r-Files generated/updated: \033[1;33m%s\033[0m" , $numFilesCreated ); |
|
285 | - printf ( "\n\r-Files not upgradeable: \033[1;33m%s\033[0m" , $numFilesIgnored ); |
|
286 | - printf ( "\n\r-Files deleted: \033[1;33m%s\033[0m" , $totalFilesDeleted ); |
|
287 | - printf ( "\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m" , $totalFiles , $this->max ); |
|
288 | - printf ( "\n\r-Diretories: \033[1;33m%s\033[0m" , $databases * $countDir ); |
|
289 | - printf ( "\n\r-Scanned tables: \033[1;33m%s\033[0m" , $totalTable ); |
|
290 | - printf ( "\n\r-Execution time: \033[1;33m%ssec\033[0m" , $this->getRunTime () ); |
|
284 | + printf("\n\r-Files generated/updated: \033[1;33m%s\033[0m", $numFilesCreated); |
|
285 | + printf("\n\r-Files not upgradeable: \033[1;33m%s\033[0m", $numFilesIgnored); |
|
286 | + printf("\n\r-Files deleted: \033[1;33m%s\033[0m", $totalFilesDeleted); |
|
287 | + printf("\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m", $totalFiles, $this->max); |
|
288 | + printf("\n\r-Diretories: \033[1;33m%s\033[0m", $databases * $countDir); |
|
289 | + printf("\n\r-Scanned tables: \033[1;33m%s\033[0m", $totalTable); |
|
290 | + printf("\n\r-Execution time: \033[1;33m%ssec\033[0m", $this->getRunTime()); |
|
291 | 291 | echo "\n------"; |
292 | 292 | } |
293 | 293 | } |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return AbstractAdapter[] |
299 | 299 | */ |
300 | - public function factoryMakerFile () |
|
300 | + public function factoryMakerFile() |
|
301 | 301 | { |
302 | - return $this->config->getMakeFileInstances (); |
|
302 | + return $this->config->getMakeFileInstances(); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return int |
309 | 309 | */ |
310 | - public function countDiretory () |
|
310 | + public function countDiretory() |
|
311 | 311 | { |
312 | - if ( null === $this->countDir ) |
|
312 | + if (null === $this->countDir) |
|
313 | 313 | { |
314 | 314 | $this->countDir = 1; |
315 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) |
|
315 | + foreach ($this->factoryMakerFile() as $abstractAdapter) |
|
316 | 316 | { |
317 | - if ( $abstractAdapter->hasDiretory () ) |
|
317 | + if ($abstractAdapter->hasDiretory()) |
|
318 | 318 | { |
319 | - ++ $this->countDir; |
|
319 | + ++$this->countDir; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
@@ -332,25 +332,25 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return String |
334 | 334 | */ |
335 | - protected function getParsedTplContents ( |
|
336 | - $tplFile , $vars = array () , \Classes\Db\DbTable $objTables = null , |
|
335 | + protected function getParsedTplContents( |
|
336 | + $tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, |
|
337 | 337 | $objMakeFile = null |
338 | - ){ |
|
338 | + ) { |
|
339 | 339 | |
340 | - $arrUrl = array ( |
|
341 | - __DIR__ , |
|
342 | - 'templates' , |
|
343 | - $this->config->framework , |
|
340 | + $arrUrl = array( |
|
341 | + __DIR__, |
|
342 | + 'templates', |
|
343 | + $this->config->framework, |
|
344 | 344 | $tplFile |
345 | 345 | ); |
346 | 346 | |
347 | - $filePath = implode ( DIRECTORY_SEPARATOR , filter_var_array ( $arrUrl ) ); |
|
347 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
348 | 348 | |
349 | - extract ( $vars ); |
|
350 | - ob_start (); |
|
349 | + extract($vars); |
|
350 | + ob_start(); |
|
351 | 351 | require $filePath; |
352 | - $data = ob_get_contents (); |
|
353 | - ob_end_clean (); |
|
352 | + $data = ob_get_contents(); |
|
353 | + ob_end_clean(); |
|
354 | 354 | |
355 | 355 | return $data; |
356 | 356 | } |
@@ -108,6 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Analisa os caminhos das pastas base |
111 | + * @param string $basePath |
|
111 | 112 | */ |
112 | 113 | public function parseLocation ( $basePath ) |
113 | 114 | { |
@@ -265,6 +266,9 @@ discard block |
||
265 | 266 | $progressBar->finish(); |
266 | 267 | } |
267 | 268 | |
269 | + /** |
|
270 | + * @param integer $cur |
|
271 | + */ |
|
268 | 272 | private function waitOfDatabase ( &$cur ) |
269 | 273 | { |
270 | 274 | printf ( "\033[1;33mWait, the database is being analyzed..\033[0m\n" ); |
@@ -329,6 +333,7 @@ discard block |
||
329 | 333 | * parse a tpl file and return the result |
330 | 334 | * |
331 | 335 | * @param String $tplFile |
336 | + * @param AbstractAdapter $objMakeFile |
|
332 | 337 | * |
333 | 338 | * @return String |
334 | 339 | */ |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | { |
161 | 161 | $update = new Update(); |
162 | 162 | $update->update () |
163 | - ->modifyTempName (); |
|
163 | + ->modifyTempName (); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | public function download ( $version ) |
167 | 167 | { |
168 | 168 | $update = new Update(); |
169 | 169 | $update->downloadVersion ( $version ) |
170 | - ->modifyTempName (); |
|
170 | + ->modifyTempName (); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | public function getVersion () |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $configIni = isset( $argv[ 'name-ini' ] ) |
194 | 194 | ? $argv[ 'name-ini' ] |
195 | 195 | : $this->_basePath |
196 | - . $this->configIniDefault; |
|
196 | + . $this->configIniDefault; |
|
197 | 197 | |
198 | 198 | $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
199 | 199 | $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | { |
208 | 208 | $frameworks = implode ( "\n\t" , $this->frameworkList ); |
209 | 209 | throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks |
210 | - . "\n\033[0m" ); |
|
210 | + . "\n\033[0m" ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | return $argv + array_filter ( $configCurrent ); |
@@ -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; |
@@ -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 | } |
@@ -14,14 +14,14 @@ |
||
14 | 14 | */ |
15 | 15 | public $pastName = 'Peer'; |
16 | 16 | protected $fileTpl = "peer.php"; |
17 | - protected $fileFixedData = array ( |
|
18 | - 'exception' => array ( |
|
19 | - 'tpl' => "model_exception.php" , |
|
17 | + protected $fileFixedData = array( |
|
18 | + 'exception' => array( |
|
19 | + 'tpl' => "model_exception.php", |
|
20 | 20 | 'name' => "Exception" |
21 | 21 | ) |
22 | 22 | ); |
23 | 23 | |
24 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
24 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
25 | 25 | { |
26 | 26 | return array(); |
27 | 27 | } |
@@ -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 | ); |
@@ -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 | } |