@@ -220,7 +220,7 @@ |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | - * @param string $Namespace |
|
223 | + * @param string $namespace |
|
224 | 224 | */ |
225 | 225 | public function setNamespace ( $namespace ) |
226 | 226 | { |
@@ -11,14 +11,14 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * @author Pedro Alarcao <[email protected]> |
13 | 13 | */ |
14 | - final private function __construct () |
|
14 | + final private function __construct() |
|
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @return \Classes\Db\DbTable |
20 | 20 | */ |
21 | - public static function getInstance(){ |
|
21 | + public static function getInstance() { |
|
22 | 22 | return new self(); |
23 | 23 | } |
24 | 24 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @var \Classes\Db\Column[] |
42 | 42 | */ |
43 | - private $columns = array (); |
|
43 | + private $columns = array(); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @var string |
@@ -50,25 +50,25 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @type \Classes\Db\Column[] |
52 | 52 | */ |
53 | - private $primarykeys = array (); |
|
53 | + private $primarykeys = array(); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @type \Classes\Db\Column[] |
57 | 57 | */ |
58 | - private $foreingkeys = array (); |
|
58 | + private $foreingkeys = array(); |
|
59 | 59 | |
60 | - private $dependence = array (); |
|
60 | + private $dependence = array(); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @type string[] |
64 | 64 | */ |
65 | - private $sequence = array (); |
|
65 | + private $sequence = array(); |
|
66 | 66 | |
67 | - public function populate ( $array ) |
|
67 | + public function populate($array) |
|
68 | 68 | { |
69 | - $this->name = $array[ 'table' ]; |
|
70 | - $this->schema = isset( $array[ 'schema' ] ) ? $array[ 'schema' ] : null; |
|
71 | - $this->database = $array[ 'database' ]; |
|
69 | + $this->name = $array['table']; |
|
70 | + $this->schema = isset($array['schema']) ? $array['schema'] : null; |
|
71 | + $this->database = $array['database']; |
|
72 | 72 | |
73 | 73 | return $this; |
74 | 74 | } |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param \Classes\Db\Column $column |
80 | 80 | */ |
81 | - public function addColumn ( Column $column ) |
|
81 | + public function addColumn(Column $column) |
|
82 | 82 | { |
83 | - $this->columns[ $column->getName () ] = $column; |
|
83 | + $this->columns[$column->getName()] = $column; |
|
84 | 84 | |
85 | 85 | return $this; |
86 | 86 | } |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return \Classes\Db\Column |
92 | 92 | */ |
93 | - public function getColumn ( $columnName ) |
|
93 | + public function getColumn($columnName) |
|
94 | 94 | { |
95 | - return $this->columns[ $columnName ]; |
|
95 | + return $this->columns[$columnName]; |
|
96 | 96 | } |
97 | 97 | |
98 | - public function hasColumn ( $columnName ) |
|
98 | + public function hasColumn($columnName) |
|
99 | 99 | { |
100 | - return isset( $this->columns[ $columnName ] ); |
|
100 | + return isset($this->columns[$columnName]); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @return \Classes\Db\Column[] |
105 | 105 | */ |
106 | - public function getPrimaryKeys () |
|
106 | + public function getPrimaryKeys() |
|
107 | 107 | { |
108 | - if ( empty ( $this->primarykeys ) ) |
|
108 | + if (empty ($this->primarykeys)) |
|
109 | 109 | { |
110 | - $this->primarykeys = array_filter ( $this->columns , function ( $column ){ return $column->isPrimaryKey (); } ); |
|
110 | + $this->primarykeys = array_filter($this->columns, function($column) { return $column->isPrimaryKey(); } ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $this->primarykeys; |
@@ -116,25 +116,25 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public function hasPrimaryKey () |
|
119 | + public function hasPrimaryKey() |
|
120 | 120 | { |
121 | - if ( empty ( $this->sequence ) ) |
|
121 | + if (empty ($this->sequence)) |
|
122 | 122 | { |
123 | - $this->getPrimaryKeys (); |
|
123 | + $this->getPrimaryKeys(); |
|
124 | 124 | } |
125 | 125 | |
126 | - return ! empty ( $this->sequence ); |
|
126 | + return ! empty ($this->sequence); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @return \Classes\Db\Column[] |
131 | 131 | */ |
132 | - public function getForeingkeys () |
|
132 | + public function getForeingkeys() |
|
133 | 133 | { |
134 | 134 | |
135 | - if ( empty ( $this->foreingkeys ) ) |
|
135 | + if (empty ($this->foreingkeys)) |
|
136 | 136 | { |
137 | - $this->foreingkeys = array_filter ( $this->columns , function ( $column ){ return $column->isForeingkey (); } ); |
|
137 | + $this->foreingkeys = array_filter($this->columns, function($column) { return $column->isForeingkey(); } ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return $this->foreingkeys; |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | /** |
145 | 145 | * @return \Classes\Db\Column[] |
146 | 146 | */ |
147 | - public function getDependences () |
|
147 | + public function getDependences() |
|
148 | 148 | { |
149 | - if ( empty ( $this->dependence ) ) |
|
149 | + if (empty ($this->dependence)) |
|
150 | 150 | { |
151 | - $this->dependence = array_filter ( $this->columns , function ( $column ){ return $column->hasDependence (); } ); |
|
151 | + $this->dependence = array_filter($this->columns, function($column) { return $column->hasDependence(); } ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | return $this->dependence; |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @return string[] |
159 | 159 | */ |
160 | - public function getSequences () |
|
160 | + public function getSequences() |
|
161 | 161 | { |
162 | - if ( empty ( $this->sequence ) ) |
|
162 | + if (empty ($this->sequence)) |
|
163 | 163 | { |
164 | - $this->sequence = array_filter ( $this->columns , function ( $column ){ return $column->hasSequence (); } ); |
|
164 | + $this->sequence = array_filter($this->columns, function($column) { return $column->hasSequence(); } ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return $this->sequence; |
@@ -170,20 +170,20 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * @return bool |
172 | 172 | */ |
173 | - public function hasSequences () |
|
173 | + public function hasSequences() |
|
174 | 174 | { |
175 | - if ( empty ( $this->sequence ) ) |
|
175 | + if (empty ($this->sequence)) |
|
176 | 176 | { |
177 | - $this->getSequences (); |
|
177 | + $this->getSequences(); |
|
178 | 178 | } |
179 | 179 | |
180 | - return ! empty ( $this->sequence ); |
|
180 | + return ! empty ($this->sequence); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | 184 | * @return \Classes\Db\Column[] |
185 | 185 | */ |
186 | - public function getColumns () |
|
186 | + public function getColumns() |
|
187 | 187 | { |
188 | 188 | return $this->columns; |
189 | 189 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * @return string |
193 | 193 | */ |
194 | - public function getName () |
|
194 | + public function getName() |
|
195 | 195 | { |
196 | 196 | return $this->name; |
197 | 197 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | /** |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function getSchema () |
|
202 | + public function getSchema() |
|
203 | 203 | { |
204 | 204 | return $this->schema; |
205 | 205 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | /** |
208 | 208 | * @return bool |
209 | 209 | */ |
210 | - public function hasSchema () |
|
210 | + public function hasSchema() |
|
211 | 211 | { |
212 | 212 | return (bool) $this->schema; |
213 | 213 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function getDatabase () |
|
218 | + public function getDatabase() |
|
219 | 219 | { |
220 | 220 | return $this->database; |
221 | 221 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | /** |
224 | 224 | * @return string |
225 | 225 | */ |
226 | - public function getNamespace () |
|
226 | + public function getNamespace() |
|
227 | 227 | { |
228 | 228 | return $this->namespace; |
229 | 229 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * @param string $Namespace |
233 | 233 | */ |
234 | - public function setNamespace ( $namespace ) |
|
234 | + public function setNamespace($namespace) |
|
235 | 235 | { |
236 | 236 | $this->namespace = $namespace; |
237 | 237 | } |
@@ -44,7 +44,6 @@ |
||
44 | 44 | /** |
45 | 45 | * Analisa e estrutura a Configuracao do generate |
46 | 46 | * |
47 | - * @param string $_path |
|
48 | 47 | * @param array $argv |
49 | 48 | * |
50 | 49 | * @return array |
@@ -24,21 +24,21 @@ discard block |
||
24 | 24 | |
25 | 25 | private $msg = "\033[0mPlease enter the value for %index% \033[1;33m[%config%]:\033[0m "; |
26 | 26 | |
27 | - private $configs = array ( |
|
28 | - 'name-ini' => 'config' , |
|
29 | - 'framework' => 'none' , |
|
30 | - 'driver' => 'pgsql' , |
|
31 | - 'environment' => 'dev' , |
|
32 | - 'host' => 'localhost' , |
|
33 | - 'database' => null , |
|
34 | - 'schema' => null , |
|
35 | - 'username' => null , |
|
27 | + private $configs = array( |
|
28 | + 'name-ini' => 'config', |
|
29 | + 'framework' => 'none', |
|
30 | + 'driver' => 'pgsql', |
|
31 | + 'environment' => 'dev', |
|
32 | + 'host' => 'localhost', |
|
33 | + 'database' => null, |
|
34 | + 'schema' => null, |
|
35 | + 'username' => null, |
|
36 | 36 | 'password' => null |
37 | 37 | ); |
38 | 38 | |
39 | - public function __construct ( $argv , $basePath ) |
|
39 | + public function __construct($argv, $basePath) |
|
40 | 40 | { |
41 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
41 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,32 +50,32 @@ discard block |
||
50 | 50 | * @return array |
51 | 51 | * @throws \Exception |
52 | 52 | */ |
53 | - private function parseConfig ( $basePath , $argv ) |
|
53 | + private function parseConfig($basePath, $argv) |
|
54 | 54 | { |
55 | 55 | $this->baseLocation = $basePath; |
56 | 56 | |
57 | - $arrayIO = array_diff_key ( $this->configs , $argv ); |
|
58 | - foreach ( $arrayIO as $index => $config ) |
|
57 | + $arrayIO = array_diff_key($this->configs, $argv); |
|
58 | + foreach ($arrayIO as $index => $config) |
|
59 | 59 | { |
60 | - $attribs = array ( "%index%" => $index , "%config%" => $config ); |
|
61 | - echo strtr ( $this->msg , $attribs ); |
|
62 | - $line = trim ( fgets ( STDIN ) ); |
|
63 | - if ( ! empty( $line ) ) |
|
60 | + $attribs = array("%index%" => $index, "%config%" => $config); |
|
61 | + echo strtr($this->msg, $attribs); |
|
62 | + $line = trim(fgets(STDIN)); |
|
63 | + if ( ! empty($line)) |
|
64 | 64 | { |
65 | - $this->configs[ $index ] = strtolower ( $line ); |
|
65 | + $this->configs[$index] = strtolower($line); |
|
66 | 66 | } |
67 | 67 | } |
68 | - $this->configs ['version'] = Config::$version; |
|
69 | - return $argv + array_filter ( $this->configs ); |
|
68 | + $this->configs ['version'] = Config::$version; |
|
69 | + return $argv + array_filter($this->configs); |
|
70 | 70 | } |
71 | 71 | |
72 | - public function run () |
|
72 | + public function run() |
|
73 | 73 | { |
74 | 74 | $path = $this->baseLocation . DIRECTORY_SEPARATOR . "configs"; |
75 | - self::makeDir ( $path ); |
|
76 | - self::makeSourcer ( |
|
77 | - $path . DIRECTORY_SEPARATOR . $this->argv[ 'name-ini' ] . '.ini' , |
|
78 | - $this->getParsedTplContents ( $this->template , $this->argv ) |
|
75 | + self::makeDir($path); |
|
76 | + self::makeSourcer( |
|
77 | + $path . DIRECTORY_SEPARATOR . $this->argv['name-ini'] . '.ini', |
|
78 | + $this->getParsedTplContents($this->template, $this->argv) |
|
79 | 79 | ); |
80 | 80 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
81 | 81 | } |
@@ -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 | } |
@@ -1,32 +1,32 @@ |
||
1 | 1 | <?php |
2 | -define ( 'PREFIX', 'orm-generator' ); |
|
3 | -define ( 'PHAR_FILE', PREFIX . '.phar' ); |
|
4 | -define ( 'PHAR_OUTPUT', 'bin' . DIRECTORY_SEPARATOR . PHAR_FILE ); |
|
5 | -define ( 'DEFAULT_STUB', 'phar-generate.php' ); |
|
6 | -define ( 'BUILD_DIR', realpath ( __DIR__ . '/build' ) ); |
|
7 | -define ( 'INCLUDE_EXTENSION', '/\.php$/' ); |
|
2 | +define('PREFIX', 'orm-generator'); |
|
3 | +define('PHAR_FILE', PREFIX . '.phar'); |
|
4 | +define('PHAR_OUTPUT', 'bin' . DIRECTORY_SEPARATOR . PHAR_FILE); |
|
5 | +define('DEFAULT_STUB', 'phar-generate.php'); |
|
6 | +define('BUILD_DIR', realpath(__DIR__ . '/build')); |
|
7 | +define('INCLUDE_EXTENSION', '/\.php$/'); |
|
8 | 8 | |
9 | 9 | try |
10 | 10 | { |
11 | - if ( file_exists ( PHAR_OUTPUT ) ) |
|
11 | + if (file_exists(PHAR_OUTPUT)) |
|
12 | 12 | { |
13 | - unlink ( PHAR_OUTPUT ); |
|
13 | + unlink(PHAR_OUTPUT); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /**************************************** |
17 | 17 | * phar file creation |
18 | 18 | ****************************************/ |
19 | - $tarphar = new Phar( PHAR_OUTPUT ); |
|
20 | - $phar = $tarphar->convertToExecutable ( Phar::PHAR ); |
|
21 | - $phar->startBuffering (); |
|
22 | - $phar->buildFromDirectory ( BUILD_DIR, INCLUDE_EXTENSION ); |
|
23 | - $stub = $phar->createDefaultStub ( DEFAULT_STUB ); |
|
24 | - $phar->setStub ( "#!/usr/bin/php\n" . $stub ); |
|
25 | - $phar->stopBuffering (); |
|
19 | + $tarphar = new Phar(PHAR_OUTPUT); |
|
20 | + $phar = $tarphar->convertToExecutable(Phar::PHAR); |
|
21 | + $phar->startBuffering(); |
|
22 | + $phar->buildFromDirectory(BUILD_DIR, INCLUDE_EXTENSION); |
|
23 | + $stub = $phar->createDefaultStub(DEFAULT_STUB); |
|
24 | + $phar->setStub("#!/usr/bin/php\n" . $stub); |
|
25 | + $phar->stopBuffering(); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | } |
29 | -catch ( Exception $e ) |
|
29 | +catch (Exception $e) |
|
30 | 30 | { |
31 | 31 | echo $e; |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -25,8 +25,7 @@ |
||
25 | 25 | $phar->stopBuffering (); |
26 | 26 | |
27 | 27 | |
28 | -} |
|
29 | -catch ( Exception $e ) |
|
28 | +} catch ( Exception $e ) |
|
30 | 29 | { |
31 | 30 | echo $e; |
32 | 31 | } |
33 | 32 | \ No newline at end of file |
@@ -71,7 +71,6 @@ |
||
71 | 71 | /** |
72 | 72 | * Retorna um Array com nome das tabelas |
73 | 73 | * |
74 | - * @param void $schema |
|
75 | 74 | * |
76 | 75 | * @return string[] |
77 | 76 | */ |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @type array|\string[] |
29 | 29 | */ |
30 | - protected $schema = array ( 'public' ); |
|
30 | + protected $schema = array('public'); |
|
31 | 31 | |
32 | - protected $dataTypesToSimple = array ( |
|
32 | + protected $dataTypesToSimple = array( |
|
33 | 33 | /* Numeric Types */ |
34 | 34 | 'smallint' => 'int', |
35 | 35 | 'integer' => 'int', |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | 'boolean' => 'boolean' |
58 | 58 | ); |
59 | 59 | |
60 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
60 | + public function __construct(AbstractAdapter $adapterConfig) |
|
61 | 61 | { |
62 | - parent::__construct ( $adapterConfig ); |
|
63 | - if ( $adapterConfig->hasSchemas () ) { |
|
64 | - $this->schema = $adapterConfig->getSchemas (); |
|
62 | + parent::__construct($adapterConfig); |
|
63 | + if ($adapterConfig->hasSchemas()) { |
|
64 | + $this->schema = $adapterConfig->getSchemas(); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | } |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string[] |
75 | 75 | */ |
76 | - public function getListNameTable () |
|
76 | + public function getListNameTable() |
|
77 | 77 | { |
78 | - if ( empty( $this->tableList ) ) { |
|
78 | + if (empty($this->tableList)) { |
|
79 | 79 | |
80 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
80 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
81 | 81 | |
82 | - $strSchema = implode ( "', '", $this->schema ); |
|
82 | + $strSchema = implode("', '", $this->schema); |
|
83 | 83 | |
84 | - $this->tableList = $this->getPDO () |
|
85 | - ->query ( |
|
84 | + $this->tableList = $this->getPDO() |
|
85 | + ->query( |
|
86 | 86 | "SELECT table_schema, |
87 | 87 | table_name |
88 | 88 | FROM information_schema.tables |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | table_name |
95 | 95 | ASC" |
96 | 96 | ) |
97 | - ->fetchAll (); |
|
97 | + ->fetchAll(); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return $this->tableList; |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public function getListColumns () |
|
108 | + public function getListColumns() |
|
109 | 109 | { |
110 | - $sqlTables = !empty($this->tablesName)?"AND c.table_name IN ( $this->tablesName )":''; |
|
111 | - $strSchema = implode ( "', '", $this->schema ); |
|
110 | + $sqlTables = ! empty($this->tablesName) ? "AND c.table_name IN ( $this->tablesName )" : ''; |
|
111 | + $strSchema = implode("', '", $this->schema); |
|
112 | 112 | |
113 | - return $this->getPDO () |
|
114 | - ->query ( |
|
113 | + return $this->getPDO() |
|
114 | + ->query( |
|
115 | 115 | "SELECT distinct |
116 | 116 | c.table_schema, |
117 | 117 | c.table_name, |
@@ -126,16 +126,16 @@ discard block |
||
126 | 126 | $sqlTables and c.table_schema IN ('$strSchema') |
127 | 127 | order by c.table_name asc" |
128 | 128 | ) |
129 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
129 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
130 | 130 | } |
131 | 131 | |
132 | - public function getListConstrant () |
|
132 | + public function getListConstrant() |
|
133 | 133 | { |
134 | - $sqlTables = !empty($this->tablesName)?"AND tc.table_name IN ( $this->tablesName )":''; |
|
135 | - $strSchema = implode ( "', '", $this->schema ); |
|
134 | + $sqlTables = ! empty($this->tablesName) ? "AND tc.table_name IN ( $this->tablesName )" : ''; |
|
135 | + $strSchema = implode("', '", $this->schema); |
|
136 | 136 | |
137 | - return $this->getPDO () |
|
138 | - ->query ( |
|
137 | + return $this->getPDO() |
|
138 | + ->query( |
|
139 | 139 | "SELECT distinct |
140 | 140 | tc.constraint_type, |
141 | 141 | tc.constraint_name, |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | AND tc.constraint_schema = ccu.constraint_schema |
158 | 158 | ORDER by tc.table_schema" |
159 | 159 | ) |
160 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
160 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -168,22 +168,22 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function getSequence ( $table, $column, $schema = 0 ) |
|
171 | + public function getSequence($table, $column, $schema = 0) |
|
172 | 172 | { |
173 | 173 | $tableTemp = $table; |
174 | - if ( 0 !== $schema ) { |
|
174 | + if (0 !== $schema) { |
|
175 | 175 | $tableTemp = $schema . '.' . $table; |
176 | 176 | } |
177 | 177 | |
178 | - $pdo = $this->getPDO (); |
|
179 | - $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$tableTemp', '$column');" ) |
|
180 | - ->fetchColumn (); |
|
178 | + $pdo = $this->getPDO(); |
|
179 | + $return1 = $pdo->query("SELECT pg_get_serial_sequence('$tableTemp', '$column');") |
|
180 | + ->fetchColumn(); |
|
181 | 181 | |
182 | - if ( !is_null ( $return1 ) ) { |
|
182 | + if ( ! is_null($return1)) { |
|
183 | 183 | return $return1; |
184 | 184 | } |
185 | 185 | |
186 | - $stmt = $pdo->prepare ( |
|
186 | + $stmt = $pdo->prepare( |
|
187 | 187 | "SELECT distinct adsrc FROM pg_attrdef AS att |
188 | 188 | INNER JOIN pg_class AS c |
189 | 189 | ON adrelid = c.oid AND c.relname = ? --table |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | " |
195 | 195 | ); |
196 | 196 | |
197 | - $stmt->bindParam ( 1, $table ); |
|
198 | - $stmt->bindParam ( 2, $column ); |
|
199 | - $stmt->bindParam ( 3, $schema ); |
|
200 | - $stmt->execute (); |
|
201 | - $return2 = $stmt->fetchColumn (); |
|
197 | + $stmt->bindParam(1, $table); |
|
198 | + $stmt->bindParam(2, $column); |
|
199 | + $stmt->bindParam(3, $schema); |
|
200 | + $stmt->execute(); |
|
201 | + $return2 = $stmt->fetchColumn(); |
|
202 | 202 | |
203 | - if ( $return2 ) { |
|
204 | - return preg_filter ( |
|
205 | - array ( |
|
203 | + if ($return2) { |
|
204 | + return preg_filter( |
|
205 | + array( |
|
206 | 206 | '/nextval\(\'/', |
207 | 207 | '/\'::regclass\)/' |
208 | 208 | ), |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @inheritDoc |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function getPDOString () |
|
220 | + public function getPDOString() |
|
221 | 221 | { |
222 | - return sprintf ( |
|
222 | + return sprintf( |
|
223 | 223 | "pgsql:host=%s;port=%s;dbname=%s", |
224 | 224 | $this->host, |
225 | 225 | $this->port, |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | * @inheritDoc |
233 | 233 | * @return string |
234 | 234 | */ |
235 | - public function getPDOSocketString () |
|
235 | + public function getPDOSocketString() |
|
236 | 236 | { |
237 | - return sprintf ( |
|
237 | + return sprintf( |
|
238 | 238 | "pgsql:unix_socket=%s;dbname=%s", |
239 | 239 | $this->socket, |
240 | 240 | $this->database |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int |
249 | 249 | */ |
250 | - public function getTotalTables () |
|
250 | + public function getTotalTables() |
|
251 | 251 | { |
252 | - if ( empty( $this->totalTables ) ) { |
|
253 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
252 | + if (empty($this->totalTables)) { |
|
253 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
254 | 254 | |
255 | - $strSchema = implode ( "', '", $this->schema ); |
|
255 | + $strSchema = implode("', '", $this->schema); |
|
256 | 256 | |
257 | - $this->totalTables = $this->getPDO () |
|
258 | - ->query ( |
|
257 | + $this->totalTables = $this->getPDO() |
|
258 | + ->query( |
|
259 | 259 | "SELECT COUNT(table_name) AS total |
260 | 260 | FROM information_schema.tables |
261 | 261 | WHERE |
262 | 262 | table_type = 'BASE TABLE' |
263 | 263 | AND table_schema IN ( '" . $strSchema . "' ) $sqlTables" |
264 | 264 | ) |
265 | - ->fetchColumn (); |
|
265 | + ->fetchColumn(); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | return (int) $this->totalTables; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | $pdo = $this->getPDO (); |
180 | 180 | $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$tableTemp', '$column');" ) |
181 | - ->fetchColumn (); |
|
181 | + ->fetchColumn (); |
|
182 | 182 | |
183 | 183 | if ( !is_null ( $return1 ) ) { |
184 | 184 | return $return1; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | $strSchema = implode ( "', '", $this->schema ); |
257 | 257 | |
258 | 258 | $this->totalTables = $this->getPDO () |
259 | - ->query ( |
|
260 | - "SELECT COUNT(table_name) AS total |
|
259 | + ->query ( |
|
260 | + "SELECT COUNT(table_name) AS total |
|
261 | 261 | FROM information_schema.tables |
262 | 262 | WHERE |
263 | 263 | table_type = 'BASE TABLE' |
264 | 264 | AND table_schema IN ( '" . $strSchema . "' ) $sqlTables" |
265 | - ) |
|
266 | - ->fetchColumn (); |
|
265 | + ) |
|
266 | + ->fetchColumn (); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | return (int) $this->totalTables; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | const SEPARETOR = "_"; |
24 | 24 | |
25 | - protected function init () |
|
25 | + protected function init() |
|
26 | 26 | { |
27 | 27 | } |
28 | 28 | |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - protected function getParams () |
|
34 | + protected function getParams() |
|
35 | 35 | { |
36 | 36 | |
37 | 37 | } |
38 | 38 | |
39 | - protected function parseFrameworkConfig () |
|
39 | + protected function parseFrameworkConfig() |
|
40 | 40 | { |
41 | 41 | // TODO: Implement parseFrameworkConfig() method. |
42 | 42 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
48 | 48 | */ |
49 | - public function getMakeFileInstances () |
|
49 | + public function getMakeFileInstances() |
|
50 | 50 | { |
51 | - return array ( |
|
52 | - DbTable::getInstance (), |
|
53 | - Entity::getInstance (), |
|
54 | - Model::getInstance () |
|
51 | + return array( |
|
52 | + DbTable::getInstance(), |
|
53 | + Entity::getInstance(), |
|
54 | + Model::getInstance() |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 |
@@ -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 | } |
@@ -12,9 +12,9 @@ |
||
12 | 12 | /** |
13 | 13 | * @var void |
14 | 14 | */ |
15 | - protected $fileTpl = "model.php"; |
|
15 | + protected $fileTpl = "model.php"; |
|
16 | 16 | |
17 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
17 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
18 | 18 | { |
19 | 19 | return array(); |
20 | 20 | } |
@@ -70,6 +70,9 @@ |
||
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | + /** |
|
74 | + * @return string |
|
75 | + */ |
|
73 | 76 | public function getDatabase (){ |
74 | 77 | return $this->database; |
75 | 78 | } |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @author Pedro Alarcao <[email protected]> |
23 | 23 | */ |
24 | - final private function __construct () |
|
24 | + final private function __construct() |
|
25 | 25 | { |
26 | 26 | } |
27 | 27 | |
28 | - public static function getInstance () |
|
28 | + public static function getInstance() |
|
29 | 29 | { |
30 | 30 | return new self(); |
31 | 31 | } |
@@ -55,34 +55,34 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return Constrant |
57 | 57 | */ |
58 | - public function populate ( $array ) |
|
58 | + public function populate($array) |
|
59 | 59 | { |
60 | - if ( isset( $array[ 'schema' ] ) ) |
|
60 | + if (isset($array['schema'])) |
|
61 | 61 | { |
62 | - $this->schema = $array[ 'schema' ]; |
|
62 | + $this->schema = $array['schema']; |
|
63 | 63 | } |
64 | 64 | |
65 | - $this->database = $array[ 'database' ]; |
|
66 | - $this->constrant = $array[ 'constrant' ]; |
|
67 | - $this->table = $array[ 'table' ]; |
|
68 | - $this->column = $array[ 'column' ]; |
|
65 | + $this->database = $array['database']; |
|
66 | + $this->constrant = $array['constrant']; |
|
67 | + $this->table = $array['table']; |
|
68 | + $this->column = $array['column']; |
|
69 | 69 | |
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function getDatabase (){ |
|
73 | + public function getDatabase() { |
|
74 | 74 | return $this->database; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function getNameConstrant () |
|
80 | + public function getNameConstrant() |
|
81 | 81 | { |
82 | 82 | return $this->constrant; |
83 | 83 | } |
84 | 84 | |
85 | - public function hasSchema () |
|
85 | + public function hasSchema() |
|
86 | 86 | { |
87 | 87 | return (bool) $this->schema; |
88 | 88 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public function getSchema () |
|
93 | + public function getSchema() |
|
94 | 94 | { |
95 | 95 | return $this->schema; |
96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @return string |
100 | 100 | */ |
101 | - public function getTable () |
|
101 | + public function getTable() |
|
102 | 102 | { |
103 | 103 | return $this->table; |
104 | 104 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - public function getColumn () |
|
109 | + public function getColumn() |
|
110 | 110 | { |
111 | 111 | return $this->column; |
112 | 112 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * @param \Classes\Db\DbTable|\Classes\Db\Constrant $table |
138 | 138 | * |
139 | - * @return mixed |
|
139 | + * @return string |
|
140 | 140 | */ |
141 | 141 | |
142 | 142 | public function createClassNamespace ( $table ) |
@@ -225,6 +225,9 @@ discard block |
||
225 | 225 | return true; |
226 | 226 | } |
227 | 227 | |
228 | + /** |
|
229 | + * @return string |
|
230 | + */ |
|
228 | 231 | protected function getFrameworkIni () |
229 | 232 | { |
230 | 233 | return $this->framworkFiles[ 'ini' ]; |
@@ -332,7 +335,6 @@ discard block |
||
332 | 335 | } |
333 | 336 | |
334 | 337 | /** |
335 | - * @param string $schema |
|
336 | 338 | * |
337 | 339 | * @return string |
338 | 340 | */ |
@@ -400,7 +400,7 @@ |
||
400 | 400 | $matches = preg_grep ( '*\.*' , $this->getTablesName () ); |
401 | 401 | if ( count ( $matches ) ) |
402 | 402 | { |
403 | - die("\033[0;31mError: Table name must not contain the schema.\033[0m\n"); |
|
403 | + die("\033[0;31mError: Table name must not contain the schema.\033[0m\n"); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 |
@@ -16,101 +16,101 @@ discard block |
||
16 | 16 | abstract class AbstractAdapter |
17 | 17 | { |
18 | 18 | |
19 | - protected $arrConfig = array ( |
|
19 | + protected $arrConfig = array( |
|
20 | 20 | ############################# DATABASE |
21 | 21 | //Driver do banco de dados |
22 | - 'driver' => null , |
|
22 | + 'driver' => null, |
|
23 | 23 | //Nome do banco de dados |
24 | - 'database' => null , |
|
24 | + 'database' => null, |
|
25 | 25 | //Host do banco |
26 | - 'host' => 'localhost' , |
|
26 | + 'host' => 'localhost', |
|
27 | 27 | //Port do banco |
28 | - 'port' => '' , |
|
28 | + 'port' => '', |
|
29 | 29 | //usuario do banco |
30 | - 'username' => null , |
|
30 | + 'username' => null, |
|
31 | 31 | //senha do banco |
32 | - 'password' => null , |
|
32 | + 'password' => null, |
|
33 | 33 | // lista de schemas do banco de dados |
34 | - 'schema' => array () , |
|
35 | - 'version' => '' , |
|
36 | - 'socket' => null , |
|
34 | + 'schema' => array(), |
|
35 | + 'version' => '', |
|
36 | + 'socket' => null, |
|
37 | 37 | |
38 | 38 | ########################### DOCS |
39 | 39 | // autor que gerou o script |
40 | - 'author' => "Pedro" , |
|
41 | - 'license' => "New BSD License" , |
|
42 | - 'copyright' => "ORM Generator - Pedro151" , |
|
43 | - 'link' => 'https://github.com/pedro151/orm-generator' , |
|
44 | - 'version' => '' , |
|
40 | + 'author' => "Pedro", |
|
41 | + 'license' => "New BSD License", |
|
42 | + 'copyright' => "ORM Generator - Pedro151", |
|
43 | + 'link' => 'https://github.com/pedro151/orm-generator', |
|
44 | + 'version' => '', |
|
45 | 45 | // data que foi gerado o script |
46 | - 'last_modify' => null , |
|
46 | + 'last_modify' => null, |
|
47 | 47 | |
48 | 48 | ########################## Ambiente/Arquivos |
49 | 49 | |
50 | 50 | // Nome do framework para o adapter |
51 | - 'framework' => null , |
|
51 | + 'framework' => null, |
|
52 | 52 | // namespace das classes |
53 | - 'namespace' => "" , |
|
53 | + 'namespace' => "", |
|
54 | 54 | // caminho onde os arquivos devem ser criados |
55 | - 'path' => 'models' , |
|
55 | + 'path' => 'models', |
|
56 | 56 | // flag para gerar pasta com o nome do driver do banco de dados |
57 | - 'folder-database' => 0 , |
|
57 | + 'folder-database' => 0, |
|
58 | 58 | // string com o nome da pastar personalizada |
59 | - 'folder-name' => '' , |
|
59 | + 'folder-name' => '', |
|
60 | 60 | |
61 | 61 | 'clean-trash' => false, |
62 | 62 | |
63 | 63 | ############################## Comandos adicionais |
64 | 64 | //flag para mostrar o status da execução ao termino do processo |
65 | - 'status' => false , |
|
65 | + 'status' => false, |
|
66 | 66 | // flags para criar todas as tabelas ou nao |
67 | - 'tables' => array () , |
|
67 | + 'tables' => array(), |
|
68 | 68 | // lista de Classes opcionais pre-definidas para serem criadas |
69 | - 'optional-classes'=> array (), |
|
69 | + 'optional-classes'=> array(), |
|
70 | 70 | //Lista de tabelas a serem ignoradas |
71 | - 'ignoreTable' => array () , |
|
71 | + 'ignoreTable' => array(), |
|
72 | 72 | ); |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @var string[] um array com todos os campos obrigatorios |
76 | 76 | */ |
77 | - protected $attRequered = array ( |
|
78 | - 'driver' => true , |
|
79 | - 'database' => true , |
|
80 | - 'host' => true , |
|
81 | - 'username' => true , |
|
77 | + protected $attRequered = array( |
|
78 | + 'driver' => true, |
|
79 | + 'database' => true, |
|
80 | + 'host' => true, |
|
81 | + 'username' => true, |
|
82 | 82 | 'path' => true |
83 | 83 | ); |
84 | 84 | |
85 | - protected $arrFunc = array (); |
|
85 | + protected $arrFunc = array(); |
|
86 | 86 | |
87 | - private $framworkFiles = array (); |
|
87 | + private $framworkFiles = array(); |
|
88 | 88 | |
89 | - public $reservedWord = array (); |
|
89 | + public $reservedWord = array(); |
|
90 | 90 | |
91 | - private static $dataTypesDefault = array ( |
|
92 | - 'int' => 'int' , |
|
93 | - 'float' => 'float' , |
|
94 | - 'string' => 'string' , |
|
95 | - 'text' => 'string' , |
|
96 | - 'date' => 'date' , |
|
97 | - 'datetime' => 'datetime' , |
|
98 | - 'timestamp' => 'timestamp' , |
|
91 | + private static $dataTypesDefault = array( |
|
92 | + 'int' => 'int', |
|
93 | + 'float' => 'float', |
|
94 | + 'string' => 'string', |
|
95 | + 'text' => 'string', |
|
96 | + 'date' => 'date', |
|
97 | + 'datetime' => 'datetime', |
|
98 | + 'timestamp' => 'timestamp', |
|
99 | 99 | 'boolean' => 'boolean' |
100 | 100 | ); |
101 | 101 | |
102 | - private static $dataTypesPhp = array ( |
|
103 | - 'int' => 'int' , |
|
104 | - 'float' => 'float' , |
|
105 | - 'string' => 'string' , |
|
106 | - 'text' => 'string' , |
|
107 | - 'date' => 'string' , |
|
108 | - 'datetime' => 'string' , |
|
109 | - 'timestamp' => 'string' , |
|
102 | + private static $dataTypesPhp = array( |
|
103 | + 'int' => 'int', |
|
104 | + 'float' => 'float', |
|
105 | + 'string' => 'string', |
|
106 | + 'text' => 'string', |
|
107 | + 'date' => 'string', |
|
108 | + 'datetime' => 'string', |
|
109 | + 'timestamp' => 'string', |
|
110 | 110 | 'boolean' => 'boolean' |
111 | 111 | ); |
112 | 112 | |
113 | - protected $dataTypes = array (); |
|
113 | + protected $dataTypes = array(); |
|
114 | 114 | |
115 | 115 | const SEPARETOR = ""; |
116 | 116 | |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return bool |
121 | 121 | */ |
122 | - protected function checkConfig () |
|
122 | + protected function checkConfig() |
|
123 | 123 | { |
124 | - if ( array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ) ) |
|
124 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) |
|
125 | 125 | { |
126 | 126 | return false; |
127 | 127 | } |
@@ -134,33 +134,33 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return array |
136 | 136 | */ |
137 | - abstract protected function getParams (); |
|
137 | + abstract protected function getParams(); |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Popula as config do generater com as configuraçoes do framework |
141 | 141 | * |
142 | 142 | * @return mixed |
143 | 143 | */ |
144 | - abstract protected function parseFrameworkConfig (); |
|
144 | + abstract protected function parseFrameworkConfig(); |
|
145 | 145 | |
146 | 146 | /** |
147 | 147 | * Cria Instancias dos arquivos que devem ser gerados |
148 | 148 | * |
149 | 149 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
150 | 150 | */ |
151 | - abstract public function getMakeFileInstances (); |
|
151 | + abstract public function getMakeFileInstances(); |
|
152 | 152 | |
153 | - abstract protected function init (); |
|
153 | + abstract protected function init(); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * retorna a base do Namespace |
157 | 157 | * |
158 | 158 | * @return array |
159 | 159 | */ |
160 | - protected function getBaseNamespace () |
|
160 | + protected function getBaseNamespace() |
|
161 | 161 | { |
162 | - return array ( |
|
163 | - $this->arrConfig[ 'namespace' ] , |
|
162 | + return array( |
|
163 | + $this->arrConfig['namespace'], |
|
164 | 164 | 'Model' |
165 | 165 | ); |
166 | 166 | } |
@@ -171,54 +171,54 @@ discard block |
||
171 | 171 | * @return mixed |
172 | 172 | */ |
173 | 173 | |
174 | - public function createClassNamespace ( $table ) |
|
174 | + public function createClassNamespace($table) |
|
175 | 175 | { |
176 | - $arrNames = $this->getBaseNamespace (); |
|
176 | + $arrNames = $this->getBaseNamespace(); |
|
177 | 177 | |
178 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
179 | - && $this->arrConfig[ 'folder-database' ] |
|
178 | + if (isset($this->arrConfig['folder-database']) |
|
179 | + && $this->arrConfig['folder-database'] |
|
180 | 180 | ) |
181 | 181 | { |
182 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
182 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
186 | - && $this->arrConfig[ 'folder-name' ] |
|
185 | + if (isset($this->arrConfig['folder-name']) |
|
186 | + && $this->arrConfig['folder-name'] |
|
187 | 187 | ) |
188 | 188 | { |
189 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
189 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( $table->hasSchema () ) |
|
192 | + if ($table->hasSchema()) |
|
193 | 193 | { |
194 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getSchema () ) ); |
|
194 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); |
|
195 | 195 | } else |
196 | 196 | { |
197 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getDatabase () ) ); |
|
197 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); |
|
198 | 198 | } |
199 | 199 | |
200 | - return implode ( static::SEPARETOR , array_filter ( $arrNames ) ); |
|
200 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
201 | 201 | } |
202 | 202 | |
203 | - public function __construct ( $array ) |
|
203 | + public function __construct($array) |
|
204 | 204 | { |
205 | 205 | $this->dataTypes = $this->dataTypes + self::$dataTypesDefault; |
206 | - $array += array ( |
|
207 | - 'version' => Config::$version , |
|
208 | - 'author' => ucfirst ( get_current_user () ) , |
|
209 | - 'last_modify' => date ( "d-m-Y" ) |
|
206 | + $array += array( |
|
207 | + 'version' => Config::$version, |
|
208 | + 'author' => ucfirst(get_current_user()), |
|
209 | + 'last_modify' => date("d-m-Y") |
|
210 | 210 | ); |
211 | 211 | |
212 | - $this->setFrameworkFiles ( $array ); |
|
213 | - $this->parseFrameworkConfig (); |
|
214 | - $this->setParams ( $this->getParams () ); |
|
215 | - $this->setParams ( $array ); |
|
216 | - $this->init (); |
|
217 | - $this->validTableNames (); |
|
218 | - if ( ! $this->isValid () ) |
|
212 | + $this->setFrameworkFiles($array); |
|
213 | + $this->parseFrameworkConfig(); |
|
214 | + $this->setParams($this->getParams()); |
|
215 | + $this->setParams($array); |
|
216 | + $this->init(); |
|
217 | + $this->validTableNames(); |
|
218 | + if ( ! $this->isValid()) |
|
219 | 219 | { |
220 | - $var = array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ); |
|
221 | - throw new Exception( $var ); |
|
220 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
221 | + throw new Exception($var); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
@@ -227,43 +227,43 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param $array |
229 | 229 | */ |
230 | - public function setFrameworkFiles ( $array ) |
|
230 | + public function setFrameworkFiles($array) |
|
231 | 231 | { |
232 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) |
|
233 | - ? $array[ 'framework-path-library' ] : null; |
|
232 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) |
|
233 | + ? $array['framework-path-library'] : null; |
|
234 | 234 | |
235 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) |
|
236 | - ? $array[ 'framework-ini' ] : null; |
|
235 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) |
|
236 | + ? $array['framework-ini'] : null; |
|
237 | 237 | |
238 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) |
|
239 | - ? $array[ 'environment' ] : 'production'; |
|
238 | + $this->framworkFiles['environment'] = isset($array['environment']) |
|
239 | + ? $array['environment'] : 'production'; |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
243 | - protected function isValidFrameworkFiles () |
|
243 | + protected function isValidFrameworkFiles() |
|
244 | 244 | { |
245 | - if ( ! is_file ( $this->framworkFiles[ 'ini' ] ) ) |
|
245 | + if ( ! is_file($this->framworkFiles['ini'])) |
|
246 | 246 | { |
247 | 247 | return false; |
248 | 248 | } |
249 | 249 | |
250 | - if ( ! is_dir ( $this->framworkFiles[ 'library' ] ) ) |
|
250 | + if ( ! is_dir($this->framworkFiles['library'])) |
|
251 | 251 | { |
252 | 252 | return false; |
253 | 253 | } |
254 | 254 | |
255 | - if ( ! isset ( $this->framworkFiles[ 'environment' ] ) |
|
256 | - or empty( $this->framworkFiles[ 'environment' ] ) |
|
255 | + if ( ! isset ($this->framworkFiles['environment']) |
|
256 | + or empty($this->framworkFiles['environment']) |
|
257 | 257 | ) |
258 | 258 | { |
259 | 259 | return false; |
260 | 260 | } |
261 | - set_include_path ( |
|
262 | - implode ( |
|
263 | - PATH_SEPARATOR , |
|
264 | - array ( |
|
265 | - realpath ( $this->framworkFiles[ 'library' ] ) , |
|
266 | - get_include_path () , |
|
261 | + set_include_path( |
|
262 | + implode( |
|
263 | + PATH_SEPARATOR, |
|
264 | + array( |
|
265 | + realpath($this->framworkFiles['library']), |
|
266 | + get_include_path(), |
|
267 | 267 | ) |
268 | 268 | ) |
269 | 269 | ); |
@@ -271,119 +271,119 @@ discard block |
||
271 | 271 | return true; |
272 | 272 | } |
273 | 273 | |
274 | - protected function getFrameworkIni () |
|
274 | + protected function getFrameworkIni() |
|
275 | 275 | { |
276 | - return $this->framworkFiles[ 'ini' ]; |
|
276 | + return $this->framworkFiles['ini']; |
|
277 | 277 | } |
278 | 278 | |
279 | - protected function getEnvironment () |
|
279 | + protected function getEnvironment() |
|
280 | 280 | { |
281 | - return $this->framworkFiles[ 'environment' ]; |
|
281 | + return $this->framworkFiles['environment']; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
286 | 286 | */ |
287 | - protected function isValid () |
|
287 | + protected function isValid() |
|
288 | 288 | { |
289 | - return $this->checkConfig (); |
|
289 | + return $this->checkConfig(); |
|
290 | 290 | } |
291 | 291 | |
292 | - private function setParams ( $array ) |
|
292 | + private function setParams($array) |
|
293 | 293 | { |
294 | - if ( count ( $array ) > 0 ) |
|
294 | + if (count($array) > 0) |
|
295 | 295 | { |
296 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
296 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public function getDatabase () |
|
303 | + public function getDatabase() |
|
304 | 304 | { |
305 | - return $this->arrConfig[ 'database' ]; |
|
305 | + return $this->arrConfig['database']; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | 309 | * @return bool |
310 | 310 | */ |
311 | - public function hasSchemas () |
|
311 | + public function hasSchemas() |
|
312 | 312 | { |
313 | - return ! empty ( $this->arrConfig[ 'schema' ] ); |
|
313 | + return ! empty ($this->arrConfig['schema']); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * @return string[] |
318 | 318 | */ |
319 | - public function getSchemas () |
|
319 | + public function getSchemas() |
|
320 | 320 | { |
321 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) |
|
321 | + if (is_string($this->arrConfig['schema'])) |
|
322 | 322 | { |
323 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
323 | + return array($this->arrConfig['schema']); |
|
324 | 324 | } |
325 | 325 | |
326 | - return $this->arrConfig[ 'schema' ]; |
|
326 | + return $this->arrConfig['schema']; |
|
327 | 327 | } |
328 | 328 | |
329 | - public function setSchema ( $schema ) |
|
329 | + public function setSchema($schema) |
|
330 | 330 | { |
331 | - $this->arrConfig[ 'schema' ] = $schema; |
|
331 | + $this->arrConfig['schema'] = $schema; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public function getHost () |
|
337 | + public function getHost() |
|
338 | 338 | { |
339 | - return $this->arrConfig[ 'host' ]; |
|
339 | + return $this->arrConfig['host']; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | 343 | * @return int |
344 | 344 | */ |
345 | - public function getPort () |
|
345 | + public function getPort() |
|
346 | 346 | { |
347 | - return $this->arrConfig[ 'port' ]; |
|
347 | + return $this->arrConfig['port']; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | 351 | * @return boolean |
352 | 352 | */ |
353 | - public function hasPort () |
|
353 | + public function hasPort() |
|
354 | 354 | { |
355 | - return ! empty( $this->arrConfig[ 'port' ] ); |
|
355 | + return ! empty($this->arrConfig['port']); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
359 | 359 | * @return boolean |
360 | 360 | */ |
361 | - public function isCleanTrash(){ |
|
362 | - return (boolean) $this->arrConfig[ 'clean-trash' ]; |
|
361 | + public function isCleanTrash() { |
|
362 | + return (boolean) $this->arrConfig['clean-trash']; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public function getSocket () |
|
368 | + public function getSocket() |
|
369 | 369 | { |
370 | - return $this->arrConfig[ 'socket' ]; |
|
370 | + return $this->arrConfig['socket']; |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * @return string |
375 | 375 | */ |
376 | - public function getUser () |
|
376 | + public function getUser() |
|
377 | 377 | { |
378 | - return $this->arrConfig[ 'username' ]; |
|
378 | + return $this->arrConfig['username']; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - public function getPassword () |
|
384 | + public function getPassword() |
|
385 | 385 | { |
386 | - return $this->arrConfig[ 'password' ]; |
|
386 | + return $this->arrConfig['password']; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - public function replaceReservedWord ( $palavra ) |
|
394 | + public function replaceReservedWord($palavra) |
|
395 | 395 | { |
396 | - if ( isset( $this->reservedWord[ strtolower ( $palavra ) ] ) ) |
|
396 | + if (isset($this->reservedWord[strtolower($palavra)])) |
|
397 | 397 | { |
398 | - return $this->reservedWord[ strtolower ( $palavra ) ]; |
|
398 | + return $this->reservedWord[strtolower($palavra)]; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | return $palavra; |
@@ -404,15 +404,15 @@ discard block |
||
404 | 404 | /** |
405 | 405 | * @return bool |
406 | 406 | */ |
407 | - public function isStatusEnabled () |
|
407 | + public function isStatusEnabled() |
|
408 | 408 | { |
409 | - return (bool) $this->arrConfig[ 'status' ]; |
|
409 | + return (bool) $this->arrConfig['status']; |
|
410 | 410 | } |
411 | 411 | |
412 | - public function validTableNames () |
|
412 | + public function validTableNames() |
|
413 | 413 | { |
414 | - $matches = preg_grep ( '*\.*' , $this->getTablesName () ); |
|
415 | - if ( count ( $matches ) ) |
|
414 | + $matches = preg_grep('*\.*', $this->getTablesName()); |
|
415 | + if (count($matches)) |
|
416 | 416 | { |
417 | 417 | die("\033[0;31mError: Table name must not contain the schema.\033[0m\n"); |
418 | 418 | } |
@@ -421,49 +421,49 @@ discard block |
||
421 | 421 | /** |
422 | 422 | * @return bool |
423 | 423 | */ |
424 | - public function hasTablesName (){ |
|
425 | - return ! empty( $this->arrConfig[ 'tables' ] ); |
|
424 | + public function hasTablesName() { |
|
425 | + return ! empty($this->arrConfig['tables']); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
429 | 429 | * @return string[] |
430 | 430 | */ |
431 | - public function getTablesName () |
|
431 | + public function getTablesName() |
|
432 | 432 | { |
433 | - if ( is_string ( $this->arrConfig[ 'tables' ] ) ) |
|
433 | + if (is_string($this->arrConfig['tables'])) |
|
434 | 434 | { |
435 | - return array ( $this->arrConfig[ 'tables' ] ); |
|
435 | + return array($this->arrConfig['tables']); |
|
436 | 436 | } |
437 | 437 | |
438 | - return $this->arrConfig[ 'tables' ]; |
|
438 | + return $this->arrConfig['tables']; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
442 | 442 | * @return string |
443 | 443 | */ |
444 | - public function getListTablesName(){ |
|
445 | - $str = implode("','", $this->getTablesName() ); |
|
444 | + public function getListTablesName() { |
|
445 | + $str = implode("','", $this->getTablesName()); |
|
446 | 446 | return "'$str'"; |
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | 450 | * @return bool |
451 | 451 | */ |
452 | - public function hasOptionalClasses (){ |
|
453 | - return ! empty( $this->arrConfig[ 'optional-classes' ] ); |
|
452 | + public function hasOptionalClasses() { |
|
453 | + return ! empty($this->arrConfig['optional-classes']); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
457 | 457 | * @return string[] |
458 | 458 | */ |
459 | - public function getOptionalClasses () |
|
459 | + public function getOptionalClasses() |
|
460 | 460 | { |
461 | - if ( is_string ( $this->arrConfig[ 'optional-classes' ] ) ) |
|
461 | + if (is_string($this->arrConfig['optional-classes'])) |
|
462 | 462 | { |
463 | - return array ( $this->arrConfig[ 'optional-classes' ] ); |
|
463 | + return array($this->arrConfig['optional-classes']); |
|
464 | 464 | } |
465 | 465 | |
466 | - return $this->arrConfig[ 'optional-classes' ]; |
|
466 | + return $this->arrConfig['optional-classes']; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -471,25 +471,25 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function __get ( $str ) |
|
474 | + public function __get($str) |
|
475 | 475 | { |
476 | - $arr = array ( |
|
477 | - 'namespace' , |
|
478 | - 'framework' , |
|
479 | - 'author' , |
|
480 | - 'license' , |
|
481 | - 'version' , |
|
482 | - 'copyright' , |
|
483 | - 'link' , |
|
484 | - 'last_modify' , |
|
485 | - 'path' , |
|
486 | - 'folder-database' , |
|
476 | + $arr = array( |
|
477 | + 'namespace', |
|
478 | + 'framework', |
|
479 | + 'author', |
|
480 | + 'license', |
|
481 | + 'version', |
|
482 | + 'copyright', |
|
483 | + 'link', |
|
484 | + 'last_modify', |
|
485 | + 'path', |
|
486 | + 'folder-database', |
|
487 | 487 | 'folder-name' |
488 | 488 | ); |
489 | 489 | |
490 | - if ( in_array ( $str , $arr ) ) |
|
490 | + if (in_array($str, $arr)) |
|
491 | 491 | { |
492 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
492 | + return $this->arrConfig[strtolower($str)]; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return; |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public static function convertTypeToPHP ( $type ) |
|
503 | + public static function convertTypeToPHP($type) |
|
504 | 504 | { |
505 | - return self::$dataTypesPhp[ $type ]; |
|
505 | + return self::$dataTypesPhp[$type]; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return string |
512 | 512 | */ |
513 | - public static function convertTypeToDefault ( $type ) |
|
513 | + public static function convertTypeToDefault($type) |
|
514 | 514 | { |
515 | - return self::$dataTypesDefault[ $type ]; |
|
515 | + return self::$dataTypesDefault[$type]; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - public function convertTypeToTypeFramework ( $type ) |
|
523 | + public function convertTypeToTypeFramework($type) |
|
524 | 524 | { |
525 | - return $this->dataTypes[ $type ]; |
|
525 | + return $this->dataTypes[$type]; |
|
526 | 526 | } |
527 | 527 | } |