@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private $fileName; |
22 | 22 | |
23 | - private function __construct (){ } |
|
23 | + private function __construct() { } |
|
24 | 24 | |
25 | - public static function getInstance ( $args = array () ) |
|
25 | + public static function getInstance($args = array()) |
|
26 | 26 | { |
27 | 27 | $obj = new FilesFixeds(); |
28 | - if ( key_exists ( 'tpl' , $args ) ) |
|
28 | + if (key_exists('tpl', $args)) |
|
29 | 29 | { |
30 | - $obj->setTpl ( $args[ 'tpl' ] ); |
|
30 | + $obj->setTpl($args['tpl']); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( key_exists ( 'name' , $args ) ) |
|
33 | + if (key_exists('name', $args)) |
|
34 | 34 | { |
35 | - $obj->setFileName ( $args[ 'name' ] ); |
|
35 | + $obj->setFileName($args['name']); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | return $obj; |
39 | 39 | } |
40 | 40 | |
41 | - public function hasData () |
|
41 | + public function hasData() |
|
42 | 42 | { |
43 | - return $this->hasTpl () && $this->hasFileName (); |
|
43 | + return $this->hasTpl() && $this->hasFileName(); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @return bool |
48 | 48 | */ |
49 | - public function hasTpl () |
|
49 | + public function hasTpl() |
|
50 | 50 | { |
51 | - return ! empty( $this->tpl ); |
|
51 | + return ! empty($this->tpl); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @return bool |
56 | 56 | */ |
57 | - public function hasFileName () |
|
57 | + public function hasFileName() |
|
58 | 58 | { |
59 | - return ! empty( $this->fileName ); |
|
59 | + return ! empty($this->fileName); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function getTpl () |
|
65 | + public function getTpl() |
|
66 | 66 | { |
67 | 67 | return $this->tpl; |
68 | 68 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @param string $tpl |
72 | 72 | */ |
73 | - public function setTpl ( $tpl ) |
|
73 | + public function setTpl($tpl) |
|
74 | 74 | { |
75 | 75 | $this->tpl = $tpl; |
76 | 76 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - public function getFileName () |
|
81 | + public function getFileName() |
|
82 | 82 | { |
83 | 83 | return $this->fileName; |
84 | 84 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @param string $fileName |
88 | 88 | */ |
89 | - public function setFileName ( $fileName ) |
|
89 | + public function setFileName($fileName) |
|
90 | 90 | { |
91 | 91 | $this->fileName = $fileName; |
92 | 92 | } |
@@ -151,6 +151,10 @@ |
||
151 | 151 | return stream_get_contents ( $handle ); |
152 | 152 | } |
153 | 153 | |
154 | + /** |
|
155 | + * @param string $url |
|
156 | + * @param string $content |
|
157 | + */ |
|
154 | 158 | public function putContent ( $url , $content ) |
155 | 159 | { |
156 | 160 | switch ( $this->objProtocol->getProtocol () ) |
@@ -227,11 +227,11 @@ |
||
227 | 227 | function progressCallback ( $download_size , $downloaded_size , $upload_size , $uploaded_size ) |
228 | 228 | { |
229 | 229 | ProgressBar::getInstance () |
230 | - ->clear () |
|
231 | - ->setMaxByte ( $download_size ) |
|
232 | - ->setProgress ( $downloaded_size ) |
|
233 | - ->render () |
|
234 | - ->finish (); |
|
230 | + ->clear () |
|
231 | + ->setMaxByte ( $download_size ) |
|
232 | + ->setProgress ( $downloaded_size ) |
|
233 | + ->render () |
|
234 | + ->finish (); |
|
235 | 235 | |
236 | 236 | } |
237 | 237 |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | abstract class AbstractContent |
15 | 15 | { |
16 | 16 | |
17 | - private static $opts = array ( |
|
18 | - 'http' => array ( |
|
19 | - 'method' => 'GET' , |
|
20 | - 'header' => array ( |
|
17 | + private static $opts = array( |
|
18 | + 'http' => array( |
|
19 | + 'method' => 'GET', |
|
20 | + 'header' => array( |
|
21 | 21 | 'User-Agent: PHP' |
22 | 22 | ) |
23 | 23 | ) |
@@ -35,22 +35,22 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @type array |
37 | 37 | */ |
38 | - private $content = array (); |
|
38 | + private $content = array(); |
|
39 | 39 | |
40 | - protected function __construct () |
|
40 | + protected function __construct() |
|
41 | 41 | { |
42 | - $this->objProtocol = ProtocolFileContent::getInstance (); |
|
43 | - $this->init (); |
|
42 | + $this->objProtocol = ProtocolFileContent::getInstance(); |
|
43 | + $this->init(); |
|
44 | 44 | } |
45 | 45 | |
46 | - protected function init (){ } |
|
46 | + protected function init() { } |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return \Classes\Update\Content |
50 | 50 | */ |
51 | - public static function getInstance () |
|
51 | + public static function getInstance() |
|
52 | 52 | { |
53 | - if ( empty( self::$objContent ) ) |
|
53 | + if (empty(self::$objContent)) |
|
54 | 54 | { |
55 | 55 | self::$objContent = new static(); |
56 | 56 | } |
@@ -63,26 +63,26 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return string |
65 | 65 | */ |
66 | - public function getContent ( $url , $progress = false ) |
|
66 | + public function getContent($url, $progress = false) |
|
67 | 67 | { |
68 | - if ( ! isset( $this->content[ $url ] ) ) |
|
68 | + if ( ! isset($this->content[$url])) |
|
69 | 69 | { |
70 | - $this->content[ $url ] = ''; |
|
71 | - switch ( $this->objProtocol->getProtocol () ) |
|
70 | + $this->content[$url] = ''; |
|
71 | + switch ($this->objProtocol->getProtocol()) |
|
72 | 72 | { |
73 | 73 | case 'curl': |
74 | - $this->content[ $url ] = $this->getCurlContent ( $url , $progress ); |
|
74 | + $this->content[$url] = $this->getCurlContent($url, $progress); |
|
75 | 75 | break; |
76 | 76 | case 'file_content': |
77 | - $this->content[ $url ] = $this->getFileContent ( $url , $progress ); |
|
77 | + $this->content[$url] = $this->getFileContent($url, $progress); |
|
78 | 78 | break; |
79 | 79 | case 'steam_content': |
80 | - $this->content[ $url ] = $this->getStreamContent ( $url , $progress ); |
|
80 | + $this->content[$url] = $this->getStreamContent($url, $progress); |
|
81 | 81 | break; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - return $this->content[ $url ]; |
|
85 | + return $this->content[$url]; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,21 +90,21 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - protected function getCurlContent ( $url , $progress = false ) |
|
93 | + protected function getCurlContent($url, $progress = false) |
|
94 | 94 | { |
95 | - $conn = curl_init ( $url ); |
|
96 | - curl_setopt ( $conn , CURLOPT_RETURNTRANSFER , true ); |
|
97 | - curl_setopt ( $conn , CURLOPT_BINARYTRANSFER , true ); |
|
98 | - curl_setopt ( $conn , CURLOPT_USERAGENT , self::$opts[ 'http' ][ 'method' ] ); |
|
99 | - if ( $progress ) |
|
95 | + $conn = curl_init($url); |
|
96 | + curl_setopt($conn, CURLOPT_RETURNTRANSFER, true); |
|
97 | + curl_setopt($conn, CURLOPT_BINARYTRANSFER, true); |
|
98 | + curl_setopt($conn, CURLOPT_USERAGENT, self::$opts['http']['method']); |
|
99 | + if ($progress) |
|
100 | 100 | { |
101 | - curl_setopt ( $conn , CURLOPT_NOPROGRESS , false ); |
|
102 | - curl_setopt ( $conn , CURLOPT_PROGRESSFUNCTION , array ( |
|
103 | - $this , 'progressCallback' |
|
104 | - ) ); |
|
101 | + curl_setopt($conn, CURLOPT_NOPROGRESS, false); |
|
102 | + curl_setopt($conn, CURLOPT_PROGRESSFUNCTION, array( |
|
103 | + $this, 'progressCallback' |
|
104 | + )); |
|
105 | 105 | } |
106 | - $url_get_contents_data = ( curl_exec ( $conn ) ); |
|
107 | - curl_close ( $conn ); |
|
106 | + $url_get_contents_data = (curl_exec($conn)); |
|
107 | + curl_close($conn); |
|
108 | 108 | |
109 | 109 | return $url_get_contents_data; |
110 | 110 | } |
@@ -114,19 +114,19 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - protected function getFileContent ( $url , $progress = false ) |
|
117 | + protected function getFileContent($url, $progress = false) |
|
118 | 118 | { |
119 | - $context = stream_context_create ( self::$opts ); |
|
120 | - if ( $progress ) |
|
119 | + $context = stream_context_create(self::$opts); |
|
120 | + if ($progress) |
|
121 | 121 | { |
122 | - stream_context_set_params ( $context , array ( |
|
123 | - "notification" => array ( |
|
124 | - $this , 'stream_notification_callback' |
|
122 | + stream_context_set_params($context, array( |
|
123 | + "notification" => array( |
|
124 | + $this, 'stream_notification_callback' |
|
125 | 125 | ) |
126 | - ) ); |
|
126 | + )); |
|
127 | 127 | } |
128 | 128 | |
129 | - return file_get_contents ( $url , false , $context ); |
|
129 | + return file_get_contents($url, false, $context); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,52 +134,52 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return string |
136 | 136 | */ |
137 | - protected function getStreamContent ( $url , $progress = false ) |
|
137 | + protected function getStreamContent($url, $progress = false) |
|
138 | 138 | { |
139 | - $context = stream_context_create ( self::$opts ); |
|
140 | - if ( $progress ) |
|
139 | + $context = stream_context_create(self::$opts); |
|
140 | + if ($progress) |
|
141 | 141 | { |
142 | - stream_context_set_params ( $context , array ( |
|
143 | - "notification" => array ( |
|
144 | - $this , 'stream_notification_callback' |
|
142 | + stream_context_set_params($context, array( |
|
143 | + "notification" => array( |
|
144 | + $this, 'stream_notification_callback' |
|
145 | 145 | ) |
146 | - ) ); |
|
146 | + )); |
|
147 | 147 | } |
148 | 148 | |
149 | - $handle = fopen ( $url , "r" , null , $context ); |
|
149 | + $handle = fopen($url, "r", null, $context); |
|
150 | 150 | |
151 | - return stream_get_contents ( $handle ); |
|
151 | + return stream_get_contents($handle); |
|
152 | 152 | } |
153 | 153 | |
154 | - public function putContent ( $url , $content ) |
|
154 | + public function putContent($url, $content) |
|
155 | 155 | { |
156 | - switch ( $this->objProtocol->getProtocol () ) |
|
156 | + switch ($this->objProtocol->getProtocol()) |
|
157 | 157 | { |
158 | 158 | case 'curl': |
159 | - $this->putFopen ( $url , $content ); |
|
159 | + $this->putFopen($url, $content); |
|
160 | 160 | break; |
161 | 161 | case 'steam_content': |
162 | 162 | case 'file_content': |
163 | - $this->putFileContent ( $url , $content ); |
|
163 | + $this->putFileContent($url, $content); |
|
164 | 164 | break; |
165 | 165 | } |
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - public function putFileContent ( $url , $content ) |
|
169 | + public function putFileContent($url, $content) |
|
170 | 170 | { |
171 | 171 | // check if all is OK |
172 | - if ( file_put_contents ( $url , $content ) ) |
|
172 | + if (file_put_contents($url, $content)) |
|
173 | 173 | { |
174 | - ProgressBar::getInstance ()->finish (); |
|
174 | + ProgressBar::getInstance()->finish(); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - public function putFopen ( $url , $content ) |
|
178 | + public function putFopen($url, $content) |
|
179 | 179 | { |
180 | - $fp = fopen ( $url , "a" ); |
|
181 | - fwrite ( $fp , $content ); |
|
182 | - fclose ( $fp ); |
|
180 | + $fp = fopen($url, "a"); |
|
181 | + fwrite($fp, $content); |
|
182 | + fclose($fp); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -192,46 +192,46 @@ discard block |
||
192 | 192 | * @param $bytes_transferred |
193 | 193 | * @param $bytes_max |
194 | 194 | */ |
195 | - public function stream_notification_callback ( $notificationCode , $severity , $message , $messageCode , $bytesTransferred , $bytesMax ) |
|
195 | + public function stream_notification_callback($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax) |
|
196 | 196 | { |
197 | - $objProgress = ProgressBar::getInstance (); |
|
198 | - switch ( $notificationCode ) |
|
197 | + $objProgress = ProgressBar::getInstance(); |
|
198 | + switch ($notificationCode) |
|
199 | 199 | { |
200 | 200 | case STREAM_NOTIFY_RESOLVE: |
201 | 201 | case STREAM_NOTIFY_AUTH_REQUIRED: |
202 | 202 | case STREAM_NOTIFY_FAILURE: |
203 | 203 | case STREAM_NOTIFY_AUTH_RESULT: |
204 | - var_dump ( $notificationCode , $severity , $message , $messageCode , $bytesTransferred , $bytesMax ); |
|
204 | + var_dump($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax); |
|
205 | 205 | /* Ignore */ |
206 | 206 | break; |
207 | 207 | case STREAM_NOTIFY_CONNECT: |
208 | 208 | echo "\033[1;32mConnected...\033[0m\n"; |
209 | 209 | break; |
210 | 210 | case STREAM_NOTIFY_REDIRECTED: |
211 | - $objProgress->clear (); |
|
211 | + $objProgress->clear(); |
|
212 | 212 | break; |
213 | 213 | case STREAM_NOTIFY_FILE_SIZE_IS: |
214 | - $objProgress->clear ()->setMaxByte ( $bytesMax ); |
|
214 | + $objProgress->clear()->setMaxByte($bytesMax); |
|
215 | 215 | break; |
216 | 216 | case STREAM_NOTIFY_PROGRESS: |
217 | - $objProgress->setProgress ( $bytesTransferred ) |
|
218 | - ->render (); |
|
217 | + $objProgress->setProgress($bytesTransferred) |
|
218 | + ->render(); |
|
219 | 219 | break; |
220 | 220 | case STREAM_NOTIFY_COMPLETED: |
221 | - $objProgress->finish (); |
|
221 | + $objProgress->finish(); |
|
222 | 222 | break; |
223 | 223 | } |
224 | 224 | |
225 | 225 | } |
226 | 226 | |
227 | - function progressCallback ( $download_size , $downloaded_size , $upload_size , $uploaded_size ) |
|
227 | + function progressCallback($download_size, $downloaded_size, $upload_size, $uploaded_size) |
|
228 | 228 | { |
229 | - ProgressBar::getInstance () |
|
230 | - ->clear () |
|
231 | - ->setMaxByte ( $download_size ) |
|
232 | - ->setProgress ( $downloaded_size ) |
|
233 | - ->render () |
|
234 | - ->finish (); |
|
229 | + ProgressBar::getInstance() |
|
230 | + ->clear() |
|
231 | + ->setMaxByte($download_size) |
|
232 | + ->setProgress($downloaded_size) |
|
233 | + ->render() |
|
234 | + ->finish(); |
|
235 | 235 | |
236 | 236 | } |
237 | 237 |
@@ -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,56 +67,56 @@ 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 | - 'clean-trash' => 'delete all files that do not belong to your Database due' , |
|
86 | - 'status' => 'show status of implementation carried out after completing the process.' , |
|
87 | - 'version' => 'shows the version of orm-generator.' , |
|
88 | - 'help' => "help command explaining all the options and manner of use." , |
|
89 | - 'path' => "specify where to create the files (default is current directory)." , |
|
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 | + 'clean-trash' => 'delete all files that do not belong to your Database due', |
|
86 | + 'status' => 'show status of implementation carried out after completing the process.', |
|
87 | + 'version' => 'shows the version of orm-generator.', |
|
88 | + 'help' => "help command explaining all the options and manner of use.", |
|
89 | + 'path' => "specify where to create the files (default is current directory).", |
|
90 | 90 | 'update' => ".", |
91 | 91 | 'download' => "" |
92 | 92 | ); |
93 | 93 | |
94 | - public function __construct ( $argv , $basePath , $numArgs ) |
|
94 | + public function __construct($argv, $basePath, $numArgs) |
|
95 | 95 | { |
96 | - if ( array_key_exists ( 'help' , $argv ) or ( $numArgs > 1 |
|
97 | - && count ( $argv ) < 1 ) |
|
96 | + if (array_key_exists('help', $argv) or ($numArgs > 1 |
|
97 | + && count($argv) < 1) |
|
98 | 98 | ) |
99 | 99 | { |
100 | - die ( $this->getUsage () ); |
|
100 | + die ($this->getUsage()); |
|
101 | 101 | } |
102 | - if ( array_key_exists ( 'version' , $argv ) ) |
|
102 | + if (array_key_exists('version', $argv)) |
|
103 | 103 | { |
104 | - die ( $this->getVersion () ); |
|
104 | + die ($this->getVersion()); |
|
105 | 105 | } |
106 | - if ( array_key_exists ( 'status' , $argv ) ) |
|
106 | + if (array_key_exists('status', $argv)) |
|
107 | 107 | { |
108 | - $argv[ 'status' ] = true; |
|
108 | + $argv['status'] = true; |
|
109 | 109 | } |
110 | - if ( array_key_exists ( 'update' , $argv ) ) |
|
110 | + if (array_key_exists('update', $argv)) |
|
111 | 111 | { |
112 | - die ( $this->update () ); |
|
112 | + die ($this->update()); |
|
113 | 113 | } |
114 | - if ( array_key_exists ( 'download' , $argv ) ) |
|
114 | + if (array_key_exists('download', $argv)) |
|
115 | 115 | { |
116 | - die ( $this->download ( $argv[ 'download' ] ) ); |
|
116 | + die ($this->download($argv['download'])); |
|
117 | 117 | } |
118 | 118 | |
119 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
119 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - public function getUsage () |
|
127 | + public function getUsage() |
|
128 | 128 | { |
129 | - $version = $this->getVersion (); |
|
130 | - $list = $this->renderParam (); |
|
129 | + $version = $this->getVersion(); |
|
130 | + $list = $this->renderParam(); |
|
131 | 131 | |
132 | 132 | return <<<EOF |
133 | 133 | parameters: |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | EOF; |
139 | 139 | } |
140 | 140 | |
141 | - public function renderParam () |
|
141 | + public function renderParam() |
|
142 | 142 | { |
143 | 143 | $return = ""; |
144 | - foreach ( $this->parameterList as $param => $desc ) |
|
144 | + foreach ($this->parameterList as $param => $desc) |
|
145 | 145 | { |
146 | - if ( strlen ( $param ) < 5 ) |
|
146 | + if (strlen($param) < 5) |
|
147 | 147 | { |
148 | 148 | $return .= "\t--" . $param . "\t\t: " . $desc . "\n"; |
149 | 149 | } else |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | return $return; |
157 | 157 | } |
158 | 158 | |
159 | - public function update () |
|
159 | + public function update() |
|
160 | 160 | { |
161 | 161 | $update = new Update(); |
162 | - $update->update () |
|
163 | - ->modifyTempName (); |
|
162 | + $update->update() |
|
163 | + ->modifyTempName(); |
|
164 | 164 | } |
165 | 165 | |
166 | - public function download ( $version ) |
|
166 | + public function download($version) |
|
167 | 167 | { |
168 | 168 | $update = new Update(); |
169 | - $update->downloadVersion ( $version ) |
|
170 | - ->modifyTempName (); |
|
169 | + $update->downloadVersion($version) |
|
170 | + ->modifyTempName(); |
|
171 | 171 | } |
172 | 172 | |
173 | - public function getVersion () |
|
173 | + public function getVersion() |
|
174 | 174 | { |
175 | 175 | $version = new Version(); |
176 | 176 | |
@@ -186,31 +186,31 @@ discard block |
||
186 | 186 | * @return array |
187 | 187 | * @throws \Exception |
188 | 188 | */ |
189 | - private function parseConfig ( $basePath , $argv ) |
|
189 | + private function parseConfig($basePath, $argv) |
|
190 | 190 | { |
191 | 191 | $this->_basePath = $basePath; |
192 | 192 | |
193 | - $configIni = isset( $argv[ 'name-ini' ] ) |
|
194 | - ? $argv[ 'name-ini' ] |
|
193 | + $configIni = isset($argv['name-ini']) |
|
194 | + ? $argv['name-ini'] |
|
195 | 195 | : $this->_basePath |
196 | 196 | . $this->configIniDefault; |
197 | 197 | |
198 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
199 | - $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
|
198 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
199 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
200 | 200 | |
201 | - if ( ! isset( $configCurrent[ 'framework' ] ) ) |
|
201 | + if ( ! isset($configCurrent['framework'])) |
|
202 | 202 | { |
203 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
203 | + throw new \Exception("configure which framework you want to use! \n"); |
|
204 | 204 | } |
205 | 205 | |
206 | - if ( ! in_array ( $configCurrent[ 'framework' ] , $this->frameworkList ) ) |
|
206 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) |
|
207 | 207 | { |
208 | - $frameworks = implode ( "\n\t" , $this->frameworkList ); |
|
209 | - throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks |
|
210 | - . "\n\033[0m" ); |
|
208 | + $frameworks = implode("\n\t", $this->frameworkList); |
|
209 | + throw new \Exception("list of frameworks: \n\t\033[1;33m" . $frameworks |
|
210 | + . "\n\033[0m"); |
|
211 | 211 | } |
212 | 212 | |
213 | - return $argv + array_filter ( $configCurrent ); |
|
213 | + return $argv + array_filter($configCurrent); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - private static function parseConfigEnv ( $configTemp , $argv ) |
|
223 | + private static function parseConfigEnv($configTemp, $argv) |
|
224 | 224 | { |
225 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) |
|
226 | - ? $configTemp[ key ( |
|
225 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) |
|
226 | + ? $configTemp[key( |
|
227 | 227 | $configTemp |
228 | - ) ][ 'config-env' ] : null; |
|
228 | + )]['config-env'] : null; |
|
229 | 229 | |
230 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] |
|
230 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] |
|
231 | 231 | : $thisSection; |
232 | 232 | |
233 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) |
|
233 | + if (isset($configTemp[$thisSection]['extends'])) |
|
234 | 234 | { |
235 | 235 | #faz marge da config principal com a config extendida |
236 | - return $configTemp[ $thisSection ] |
|
237 | - + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
236 | + return $configTemp[$thisSection] |
|
237 | + + $configTemp[$configTemp[$thisSection]['extends']]; |
|
238 | 238 | } |
239 | 239 | |
240 | - return $configTemp[ key ( $configTemp ) ]; |
|
240 | + return $configTemp[key($configTemp)]; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -251,32 +251,32 @@ discard block |
||
251 | 251 | * @throws \Exception |
252 | 252 | * @return array |
253 | 253 | */ |
254 | - protected function loadIniFile ( $filename ) |
|
254 | + protected function loadIniFile($filename) |
|
255 | 255 | { |
256 | - if ( ! is_file ( $filename ) ) |
|
256 | + if ( ! is_file($filename)) |
|
257 | 257 | { |
258 | - throw new \Exception( "\033[0;31mError: configuration file does not exist! \033[0m\n" ); |
|
258 | + throw new \Exception("\033[0;31mError: configuration file does not exist! \033[0m\n"); |
|
259 | 259 | } |
260 | 260 | |
261 | - $loaded = parse_ini_file ( $filename , true ); |
|
262 | - $iniArray = array (); |
|
263 | - foreach ( $loaded as $key => $data ) |
|
261 | + $loaded = parse_ini_file($filename, true); |
|
262 | + $iniArray = array(); |
|
263 | + foreach ($loaded as $key => $data) |
|
264 | 264 | { |
265 | - $pieces = explode ( $this->sectionSeparator , $key ); |
|
266 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
267 | - switch ( count ( $pieces ) ) |
|
265 | + $pieces = explode($this->sectionSeparator, $key); |
|
266 | + $thisSection = trim($pieces[0]); |
|
267 | + switch (count($pieces)) |
|
268 | 268 | { |
269 | 269 | case 1: |
270 | - $iniArray[ $thisSection ] = $data; |
|
270 | + $iniArray[$thisSection] = $data; |
|
271 | 271 | break; |
272 | 272 | |
273 | 273 | case 2: |
274 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
275 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ) , $data ); |
|
274 | + $extendedSection = trim($pieces[1]); |
|
275 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
276 | 276 | break; |
277 | 277 | |
278 | 278 | default: |
279 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
279 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | * @return \Classes\AdapterConfig\AbstractAdapter |
290 | 290 | * |
291 | 291 | */ |
292 | - private function factoryConfig () |
|
292 | + private function factoryConfig() |
|
293 | 293 | { |
294 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) |
|
294 | + switch (strtolower($this->argv['framework'])) |
|
295 | 295 | { |
296 | 296 | case 'zf1': |
297 | - return new ZendFrameworkOne( $this->argv ); |
|
297 | + return new ZendFrameworkOne($this->argv); |
|
298 | 298 | case 'phalcon': |
299 | - return new Phalcon( $this->argv ); |
|
299 | + return new Phalcon($this->argv); |
|
300 | 300 | default: |
301 | - return new None( $this->argv ); |
|
301 | + return new None($this->argv); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | } |
@@ -310,33 +310,33 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return AdaptersDriver\AbsractAdapter |
312 | 312 | */ |
313 | - private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
|
313 | + private function factoryDriver(AdapterConfig\AbstractAdapter $config) |
|
314 | 314 | { |
315 | - switch ( $this->argv[ 'driver' ] ) |
|
315 | + switch ($this->argv['driver']) |
|
316 | 316 | { |
317 | 317 | case 'pgsql': |
318 | 318 | case 'pdo_pgsql': |
319 | - return new Pgsql( $config ); |
|
319 | + return new Pgsql($config); |
|
320 | 320 | case 'mysql': |
321 | 321 | case 'pdo_mysql': |
322 | - return new Mysql( $config ); |
|
322 | + return new Mysql($config); |
|
323 | 323 | case 'mssql': |
324 | - return new Mssql( $config ); |
|
324 | + return new Mssql($config); |
|
325 | 325 | case 'dblib': |
326 | - return new Dblib( $config ); |
|
326 | + return new Dblib($config); |
|
327 | 327 | case 'sqlsrv': |
328 | - return new Sqlsrv( $config ); |
|
328 | + return new Sqlsrv($config); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
333 | 333 | * @return AdapterConfig\AbstractAdapter |
334 | 334 | */ |
335 | - public function getAdapterConfig () |
|
335 | + public function getAdapterConfig() |
|
336 | 336 | { |
337 | - if ( ! $this->adapterConfig instanceof AbstractAdapter ) |
|
337 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) |
|
338 | 338 | { |
339 | - $this->adapterConfig = $this->factoryConfig (); |
|
339 | + $this->adapterConfig = $this->factoryConfig(); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | return $this->adapterConfig; |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | /** |
346 | 346 | * @return AdaptersDriver\AbsractAdapter |
347 | 347 | */ |
348 | - public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
|
348 | + public function getAdapterDriver(AdapterConfig\AbstractAdapter $config) |
|
349 | 349 | { |
350 | - if ( ! $this->adapterDriver ) |
|
350 | + if ( ! $this->adapterDriver) |
|
351 | 351 | { |
352 | - $this->adapterDriver = $this->factoryDriver ( $config ); |
|
352 | + $this->adapterDriver = $this->factoryDriver($config); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | return $this->adapterDriver; |