@@ -72,6 +72,7 @@ |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | + * @param string $type |
|
75 | 76 | * @return bool |
76 | 77 | */ |
77 | 78 | private function hasEnabled ( $type ) |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private static $objProtocol; |
22 | 22 | |
23 | - private function __construct () |
|
23 | + private function __construct() |
|
24 | 24 | { |
25 | - $this->parseContentProtocol (); |
|
25 | + $this->parseContentProtocol(); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @return \Classes\Update\ProtocolFileContent |
30 | 30 | */ |
31 | - public static function getInstance () |
|
31 | + public static function getInstance() |
|
32 | 32 | { |
33 | - if ( empty( self::$objProtocol ) ) |
|
33 | + if (empty(self::$objProtocol)) |
|
34 | 34 | { |
35 | 35 | self::$objProtocol = new ProtocolFileContent(); |
36 | 36 | } |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public function hasProtocol () |
|
44 | + public function hasProtocol() |
|
45 | 45 | { |
46 | - return ! empty( $this->protocol ); |
|
46 | + return ! empty($this->protocol); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @return string |
51 | 51 | */ |
52 | - public function getProtocol () |
|
52 | + public function getProtocol() |
|
53 | 53 | { |
54 | 54 | return $this->protocol; |
55 | 55 | } |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * |
59 | 59 | */ |
60 | - private function parseContentProtocol () |
|
60 | + private function parseContentProtocol() |
|
61 | 61 | { |
62 | - if ( $this->hasEnabled ( 'file_content' ) ) |
|
62 | + if ($this->hasEnabled('file_content')) |
|
63 | 63 | { |
64 | 64 | $this->protocol = 'file_content'; |
65 | - } elseif ( $this->hasEnabled ( 'steam_content' ) ) |
|
65 | + } elseif ($this->hasEnabled('steam_content')) |
|
66 | 66 | { |
67 | 67 | $this->protocol = 'steam_content'; |
68 | - } elseif ( $this->hasEnabled ( 'curl' ) ) |
|
68 | + } elseif ($this->hasEnabled('curl')) |
|
69 | 69 | { |
70 | 70 | $this->protocol = 'curl'; |
71 | 71 | } |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | - private function hasEnabled ( $type ) |
|
77 | + private function hasEnabled($type) |
|
78 | 78 | { |
79 | - switch ( $type ) |
|
79 | + switch ($type) |
|
80 | 80 | { |
81 | 81 | case 'curl': |
82 | - return function_exists ( 'fopen' ) && function_exists ( 'curl_exec' ); |
|
82 | + return function_exists('fopen') && function_exists('curl_exec'); |
|
83 | 83 | break; |
84 | 84 | case 'file_content': |
85 | - return function_exists ( 'file_get_contents' ) && function_exists ( 'stream_get_contents' ); |
|
85 | + return function_exists('file_get_contents') && function_exists('stream_get_contents'); |
|
86 | 86 | break; |
87 | 87 | case 'steam_content': |
88 | - return function_exists ( 'fopen' ) && function_exists ( 'stream_get_contents' ); |
|
88 | + return function_exists('fopen') && function_exists('stream_get_contents'); |
|
89 | 89 | break; |
90 | 90 | } |
91 | 91 |
@@ -38,9 +38,9 @@ |
||
38 | 38 | |
39 | 39 | $this->versionUpdate = $version; |
40 | 40 | $this->tempFileName = self::$fileName |
41 | - . self::$separador |
|
42 | - . $this->versionUpdate |
|
43 | - . self::$extencion; |
|
41 | + . self::$separador |
|
42 | + . $this->versionUpdate |
|
43 | + . self::$extencion; |
|
44 | 44 | |
45 | 45 | } |
46 | 46 |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | */ |
29 | 29 | private $objGitHub; |
30 | 30 | |
31 | - public function __construct ( $version = null ) |
|
31 | + public function __construct($version = null) |
|
32 | 32 | { |
33 | - $this->objGitHub = GitHub::getInstance (); |
|
34 | - if ( is_null ( $version ) ) |
|
33 | + $this->objGitHub = GitHub::getInstance(); |
|
34 | + if (is_null($version)) |
|
35 | 35 | { |
36 | - $version = $this->objGitHub->getLastVersion (); |
|
36 | + $version = $this->objGitHub->getLastVersion(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $this->versionUpdate = $version; |
@@ -44,58 +44,58 @@ discard block |
||
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | - public function update () |
|
47 | + public function update() |
|
48 | 48 | { |
49 | - if ( Version::HasNewVersion () && ! Version::equalVersion ( $this->versionUpdate ) |
|
49 | + if (Version::HasNewVersion() && ! Version::equalVersion($this->versionUpdate) |
|
50 | 50 | ) |
51 | 51 | { |
52 | - $content = $this->objGitHub->getContent ( $this->objGitHub->getLastPhar () , true ); |
|
53 | - if ( $content ) |
|
52 | + $content = $this->objGitHub->getContent($this->objGitHub->getLastPhar(), true); |
|
53 | + if ($content) |
|
54 | 54 | { |
55 | - $this->objGitHub->putContent ( $this->tempFileName , $content ); |
|
55 | + $this->objGitHub->putContent($this->tempFileName, $content); |
|
56 | 56 | } |
57 | 57 | } else |
58 | 58 | { |
59 | - throw new \Exception ( "\033[0;31mError: Esta versão é a atual\033[0m\n" ); |
|
59 | + throw new \Exception("\033[0;31mError: Esta versão é a atual\033[0m\n"); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | return $this; |
63 | 63 | } |
64 | 64 | |
65 | - public function downloadVersion ( $version ) |
|
65 | + public function downloadVersion($version) |
|
66 | 66 | { |
67 | - if ( Version::existVersion ( $version ) && ! Version::equalVersion ( $version ) ) |
|
67 | + if (Version::existVersion($version) && ! Version::equalVersion($version)) |
|
68 | 68 | { |
69 | - $content = $this->objGitHub->getContent ( $this->objGitHub->getPharByVersion ( $version ) , true ); |
|
69 | + $content = $this->objGitHub->getContent($this->objGitHub->getPharByVersion($version), true); |
|
70 | 70 | |
71 | - if ( $content ) |
|
71 | + if ($content) |
|
72 | 72 | { |
73 | - $this->objGitHub->putContent ( $this->tempFileName , $content ); |
|
73 | + $this->objGitHub->putContent($this->tempFileName, $content); |
|
74 | 74 | } |
75 | 75 | } else |
76 | 76 | { |
77 | - if ( ! Version::existVersion ( $version ) ) |
|
77 | + if ( ! Version::existVersion($version)) |
|
78 | 78 | { |
79 | - throw new \Exception ( "\033[0;31mError: Esta versão não existe\033[0m\n" ); |
|
79 | + throw new \Exception("\033[0;31mError: Esta versão não existe\033[0m\n"); |
|
80 | 80 | } |
81 | - throw new \Exception ( "\033[0;31mError: Esta versão é a atual\033[0m\n" ); |
|
81 | + throw new \Exception("\033[0;31mError: Esta versão é a atual\033[0m\n"); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | - public function modifyTempName () |
|
87 | + public function modifyTempName() |
|
88 | 88 | { |
89 | - if ( file_exists ( realpath ( $this->tempFileName ) ) ) |
|
89 | + if (file_exists(realpath($this->tempFileName))) |
|
90 | 90 | { |
91 | - $fileName = realpath ( self::$fileName . self::$extencion ); |
|
92 | - if ( file_exists ( $fileName ) ) |
|
91 | + $fileName = realpath(self::$fileName . self::$extencion); |
|
92 | + if (file_exists($fileName)) |
|
93 | 93 | { |
94 | - unlink ( $fileName ); |
|
94 | + unlink($fileName); |
|
95 | 95 | } |
96 | 96 | |
97 | - chmod ( $this->tempFileName , 0777 ); |
|
98 | - rename ( $this->tempFileName , self::$fileName . self::$extencion ); |
|
97 | + chmod($this->tempFileName, 0777); |
|
98 | + rename($this->tempFileName, self::$fileName . self::$extencion); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 |
@@ -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 |
@@ -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 | } |
@@ -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 | ); |