@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * @type AbstractAdapter[] |
13 | 13 | */ |
14 | - private static $_instance = array (); |
|
14 | + private static $_instance = array(); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @type FilesFixeds[] |
18 | 18 | */ |
19 | - private $instanceFixedFile = array (); |
|
19 | + private $instanceFixedFile = array(); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param \Classes\MakerFile $makerFile |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return array |
26 | 26 | */ |
27 | - abstract public function parseRelation ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ); |
|
27 | + abstract public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @type string nome do arquivo template |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @type string[][] |
43 | 43 | */ |
44 | - protected $fileFixedData = array (); |
|
44 | + protected $fileFixedData = array(); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @var bool |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * |
53 | 53 | */ |
54 | - final private function __construct () |
|
54 | + final private function __construct() |
|
55 | 55 | { |
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return \Classes\AdapterMakerFile\AbstractAdapter |
60 | 60 | */ |
61 | - public static function getInstance () |
|
61 | + public static function getInstance() |
|
62 | 62 | { |
63 | - $class = get_called_class (); |
|
64 | - if ( ! isset( self::$_instance[ $class ] ) ) |
|
63 | + $class = get_called_class(); |
|
64 | + if ( ! isset(self::$_instance[$class])) |
|
65 | 65 | { |
66 | - self::$_instance[ $class ] = new $class(); |
|
66 | + self::$_instance[$class] = new $class(); |
|
67 | 67 | } |
68 | 68 | |
69 | - return self::$_instance[ $class ]; |
|
69 | + return self::$_instance[$class]; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | - public function hasDiretory () |
|
77 | + public function hasDiretory() |
|
78 | 78 | { |
79 | - return ! empty( $this->pastName ); |
|
79 | + return ! empty($this->pastName); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @return \Classes\AdapterMakerFile\FilesFixeds |
84 | 84 | */ |
85 | - public function getFilesFixeds ( $key ) |
|
85 | + public function getFilesFixeds($key) |
|
86 | 86 | { |
87 | 87 | $key = strtolower($key); |
88 | - if ( ! isset( $this->fileFixedData[ $key ] ) ) |
|
88 | + if ( ! isset($this->fileFixedData[$key])) |
|
89 | 89 | { |
90 | - throw new \Exception( 'Não existe dados para popular o FilesFixeds ' . $key ); |
|
90 | + throw new \Exception('Não existe dados para popular o FilesFixeds ' . $key); |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( !isset($this->instanceFixedFile[ $key ]) or ! $this->instanceFixedFile[ $key ] instanceof FilesFixeds ) |
|
93 | + if ( ! isset($this->instanceFixedFile[$key]) or ! $this->instanceFixedFile[$key] instanceof FilesFixeds) |
|
94 | 94 | { |
95 | - $this->instanceFixedFile[ $key ] = FilesFixeds::getInstance ( $this->fileFixedData[ $key ] ); |
|
95 | + $this->instanceFixedFile[$key] = FilesFixeds::getInstance($this->fileFixedData[$key]); |
|
96 | 96 | } |
97 | 97 | |
98 | - return $this->instanceFixedFile[ $key ]; |
|
98 | + return $this->instanceFixedFile[$key]; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return bool |
105 | 105 | */ |
106 | - public function hasFilesFixeds ( $key ) |
|
106 | + public function hasFilesFixeds($key) |
|
107 | 107 | { |
108 | - return $this->getFilesFixeds ( strtolower($key) )->hasData (); |
|
108 | + return $this->getFilesFixeds(strtolower($key))->hasData(); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public function getListFilesFixed () |
|
116 | + public function getListFilesFixed() |
|
117 | 117 | { |
118 | - return \array_keys ( $this->fileFixedData ); |
|
118 | + return \array_keys($this->fileFixedData); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @return string |
123 | 123 | */ |
124 | - public function getFileTpl () |
|
124 | + public function getFileTpl() |
|
125 | 125 | { |
126 | 126 | return $this->fileTpl; |
127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | /** |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - public function getPastName () |
|
132 | + public function getPastName() |
|
133 | 133 | { |
134 | 134 | return $this->pastName; |
135 | 135 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * @return bool |
139 | 139 | */ |
140 | - public function isOverwrite () |
|
140 | + public function isOverwrite() |
|
141 | 141 | { |
142 | 142 | return $this->overwrite; |
143 | 143 | } |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?="<?php\n"?> |
2 | 2 | |
3 | 3 | /** |
4 | - * <?=$this->config->last_modify."\n"?> |
|
4 | + * <?=$this->config->last_modify . "\n"?> |
|
5 | 5 | * |
6 | 6 | * @package <?=$this->config->namespace?>Model |
7 | 7 | * @subpackage Model |
8 | 8 | * @see Zend_Exception. <?="\n"?> |
9 | 9 | * |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
15 | - * @version <?=$this->config->version."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | + * @version <?=$this->config->version . "\n"?> |
|
16 | 16 | */ |
17 | 17 | |
18 | -class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_Exception extends Exception |
|
18 | +class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_Exception extends Exception |
|
19 | 19 | { |
20 | 20 | } |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?="<?php\n"?> |
2 | 2 | |
3 | 3 | /** |
4 | - * <?=$this->config->last_modify."\n"?> |
|
4 | + * <?=$this->config->last_modify . "\n"?> |
|
5 | 5 | * |
6 | 6 | * @package <?=$this->config->namespace?>Model |
7 | 7 | * @subpackage Model |
8 | 8 | * @see Zend_Exception. <?="\n"?> |
9 | 9 | * |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
15 | - * @version <?=$this->config->version."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | + * @version <?=$this->config->version . "\n"?> |
|
16 | 16 | */ |
17 | 17 | |
18 | -class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityException extends Exception |
|
18 | +class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityException extends Exception |
|
19 | 19 | { |
20 | 20 | } |
@@ -3,21 +3,21 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Model DbTables |
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 DbTable |
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()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$this->config->namespace?$this->config->namespace."_":""?>Model_<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
20 | +class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
21 | 21 | { |
22 | 22 | /** |
23 | 23 | * Nome da tabela do banco de dados |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @access protected |
27 | 27 | */ |
28 | 28 | protected $_name = '<?=$objTables->getName()?>'; |
29 | -<?php if($objTables->hasSchema()): ?> |
|
29 | +<?php if ($objTables->hasSchema()): ?> |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Schema da tabela do banco de dados |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @var string |
44 | 44 | * @access protected |
45 | 45 | */ |
46 | - protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>'; |
|
46 | + protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>'; |
|
47 | 47 | |
48 | -<?php if( $objTables->hasPrimaryKey() ):?> |
|
48 | +<?php if ($objTables->hasPrimaryKey()):?> |
|
49 | 49 | /** |
50 | 50 | * Nome da Primary Key |
51 | 51 | * |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @access protected |
54 | 54 | */ |
55 | 55 | protected $_primary = array( |
56 | -<?php foreach($objTables->getPrimaryKeys() as $pks):?> |
|
56 | +<?php foreach ($objTables->getPrimaryKeys() as $pks):?> |
|
57 | 57 | '<?=$pks->getName()?>', |
58 | 58 | <?php endforeach; ?> |
59 | 59 | ); |
60 | 60 | <?php endif ?> |
61 | -<?php if($this->config->{'folder-name'}):?> |
|
61 | +<?php if ($this->config->{'folder-name'}):?> |
|
62 | 62 | /** |
63 | 63 | * Initialize database adapter. |
64 | 64 | * |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | parent::_setupDatabaseAdapter(); |
74 | 74 | } |
75 | 75 | <?php endif ?> |
76 | -<?php if( $objTables->hasSequences() ) : ?> |
|
76 | +<?php if ($objTables->hasSequences()) : ?> |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Definir a lógica para os novos valores na chave primária. |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @var mixed |
83 | 83 | */ |
84 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
85 | -<?php if(strpos($this->config->driver, 'pgsql')): ?> |
|
86 | -<?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
84 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
85 | +<?php if (strpos($this->config->driver, 'pgsql')): ?> |
|
86 | +<?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
87 | 87 | protected $_sequence = '<?=$seq->getSequence() ?>'; |
88 | 88 | <?php else: ?> |
89 | 89 | protected $_sequence = true; |
@@ -3,28 +3,28 @@ |
||
3 | 3 | /** |
4 | 4 | * Mvc Model |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$objTables->getNamespace()?>\Peer |
9 | 9 | * @subpackage Model |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
15 | - * @version <?=$this->config->version."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | + * @version <?=$this->config->version . "\n"?> |
|
16 | 16 | */ |
17 | 17 | |
18 | 18 | namespace <?=$objTables->getNamespace()?>\Peer; |
19 | 19 | |
20 | -class <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends \<?=$this->config->namespace?$this->config->namespace."\\":""?>Models\<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
20 | +class <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends \<?=$this->config->namespace ? $this->config->namespace . "\\" : ""?>Models\<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
21 | 21 | { |
22 | 22 | /** |
23 | 23 | * Name of the object for static instance |
24 | 24 | * |
25 | 25 | * @var string $className |
26 | 26 | */ |
27 | - protected static $className = '<?=$objTables->getNamespace()?>\<?=$this->getClassName ( $objTables->getName () )?>'; |
|
27 | + protected static $className = '<?=$objTables->getNamespace()?>\<?=$this->getClassName($objTables->getName())?>'; |
|
28 | 28 | |
29 | 29 | /* @TODO Codifique aqui */ |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -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 |