@@ -61,7 +61,7 @@ |
||
61 | 61 | /** |
62 | 62 | * Cria Instancias dos arquivos que devem ser gerados |
63 | 63 | * |
64 | - * @return AbstractAdapter[] |
|
64 | + * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
|
65 | 65 | */ |
66 | 66 | public function getMakeFileInstances () |
67 | 67 | { |
@@ -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,31 +31,31 @@ 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 | } |
43 | 43 | |
44 | - public function createClassNamespace ( $table ) |
|
44 | + public function createClassNamespace($table) |
|
45 | 45 | { |
46 | - $arrNames = array ( |
|
47 | - $this->arrConfig[ 'namespace' ], |
|
46 | + $arrNames = array( |
|
47 | + $this->arrConfig['namespace'], |
|
48 | 48 | 'Model' |
49 | 49 | ); |
50 | - if ( $table->hasSchema () ) |
|
50 | + if ($table->hasSchema()) |
|
51 | 51 | { |
52 | - $arrNames[] = AbstractMaker::getClassName ( $table->getSchema () ); |
|
52 | + $arrNames[] = AbstractMaker::getClassName($table->getSchema()); |
|
53 | 53 | } else |
54 | 54 | { |
55 | - $arrNames[] = AbstractMaker::getClassName ( $table->getDatabase() ); |
|
55 | + $arrNames[] = AbstractMaker::getClassName($table->getDatabase()); |
|
56 | 56 | } |
57 | 57 | |
58 | - return implode ( '_', array_filter ( $arrNames ) ); |
|
58 | + return implode('_', array_filter($arrNames)); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return AbstractAdapter[] |
65 | 65 | */ |
66 | - public function getMakeFileInstances () |
|
66 | + public function getMakeFileInstances() |
|
67 | 67 | { |
68 | - return array ( |
|
69 | - DbTable::getInstance (), |
|
70 | - Entity::getInstance (), |
|
71 | - Model::getInstance () |
|
68 | + return array( |
|
69 | + DbTable::getInstance(), |
|
70 | + Entity::getInstance(), |
|
71 | + Model::getInstance() |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 |
@@ -107,7 +107,7 @@ |
||
107 | 107 | /** |
108 | 108 | * Cria Instancias dos arquivos que devem ser gerados |
109 | 109 | * |
110 | - * @return AbstractAdapter[] |
|
110 | + * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
|
111 | 111 | */ |
112 | 112 | public function getMakeFileInstances () |
113 | 113 | { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | const SEPARETOR = "_"; |
26 | 26 | |
27 | - protected function init () |
|
27 | + protected function init() |
|
28 | 28 | { |
29 | 29 | } |
30 | 30 | |
@@ -33,75 +33,75 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return array |
35 | 35 | */ |
36 | - protected function getParams () |
|
36 | + protected function getParams() |
|
37 | 37 | { |
38 | - if ( ! $this->config or !$this->isValidFrameworkFiles ()) |
|
38 | + if ( ! $this->config or ! $this->isValidFrameworkFiles()) |
|
39 | 39 | { |
40 | - return array (); |
|
40 | + return array(); |
|
41 | 41 | } |
42 | 42 | |
43 | - return array ( |
|
43 | + return array( |
|
44 | 44 | //Driver do banco de dados |
45 | - 'driver' => $this->config[ 'adapter' ] , |
|
45 | + 'driver' => $this->config['adapter'], |
|
46 | 46 | //Nome do banco de dados |
47 | - 'database' => $this->config[ 'params' ][ 'dbname' ] , |
|
47 | + 'database' => $this->config['params']['dbname'], |
|
48 | 48 | //Host do banco |
49 | - 'host' => $this->config[ 'params' ][ 'host' ] , |
|
49 | + 'host' => $this->config['params']['host'], |
|
50 | 50 | //Port do banco |
51 | - 'port' => isset( $this->config[ 'params' ][ 'port' ] ) |
|
52 | - ? $this->config[ 'params' ][ 'port' ] : '' , |
|
51 | + 'port' => isset($this->config['params']['port']) |
|
52 | + ? $this->config['params']['port'] : '', |
|
53 | 53 | //usuario do banco |
54 | - 'username' => $this->config[ 'params' ][ 'username' ] , |
|
54 | + 'username' => $this->config['params']['username'], |
|
55 | 55 | //senha do banco |
56 | - 'password' => $this->config[ 'params' ][ 'password' ] , |
|
56 | + 'password' => $this->config['params']['password'], |
|
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | - protected function parseFrameworkConfig () |
|
60 | + protected function parseFrameworkConfig() |
|
61 | 61 | { |
62 | - if(!$this->isValidFrameworkFiles ()){ |
|
62 | + if ( ! $this->isValidFrameworkFiles()) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | - $frameworkIni = $this->getFrameworkIni (); |
|
66 | + $frameworkIni = $this->getFrameworkIni(); |
|
67 | 67 | |
68 | 68 | require_once 'Zend/Config/Ini.php'; |
69 | 69 | |
70 | 70 | $objConfig = new \Zend_Config_Ini( |
71 | - realpath ( $frameworkIni ) , $this->getEnvironment () |
|
71 | + realpath($frameworkIni), $this->getEnvironment() |
|
72 | 72 | ); |
73 | 73 | |
74 | - $arrConfig = $objConfig->toArray (); |
|
74 | + $arrConfig = $objConfig->toArray(); |
|
75 | 75 | |
76 | - if ( isset( $arrConfig[ 'resources' ][ 'db' ] ) ) |
|
76 | + if (isset($arrConfig['resources']['db'])) |
|
77 | 77 | { |
78 | - $this->config = $arrConfig[ 'resources' ][ 'db' ]; |
|
78 | + $this->config = $arrConfig['resources']['db']; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - public function createClassNamespace ( $table ) |
|
82 | + public function createClassNamespace($table) |
|
83 | 83 | { |
84 | - $arrNames = array ( |
|
85 | - $this->arrConfig[ 'namespace' ] , |
|
84 | + $arrNames = array( |
|
85 | + $this->arrConfig['namespace'], |
|
86 | 86 | 'Model' |
87 | 87 | ); |
88 | 88 | |
89 | - if ( isset( $this->arrConfig['folder-database'] ) |
|
89 | + if (isset($this->arrConfig['folder-database']) |
|
90 | 90 | && $this->arrConfig['folder-database'] |
91 | 91 | ) |
92 | 92 | { |
93 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig['driver'] ); |
|
93 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
94 | 94 | } |
95 | 95 | |
96 | - if ( $table->hasSchema () ) |
|
96 | + if ($table->hasSchema()) |
|
97 | 97 | { |
98 | - $arrNames[] = AbstractMaker::getClassName ( $table->getSchema () ); |
|
98 | + $arrNames[] = AbstractMaker::getClassName($table->getSchema()); |
|
99 | 99 | } else |
100 | 100 | { |
101 | - $arrNames[] = AbstractMaker::getClassName ( $table->getDatabase () ); |
|
101 | + $arrNames[] = AbstractMaker::getClassName($table->getDatabase()); |
|
102 | 102 | } |
103 | 103 | |
104 | - return implode ( self::SEPARETOR , array_filter ( $arrNames ) ); |
|
104 | + return implode(self::SEPARETOR, array_filter($arrNames)); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return AbstractAdapter[] |
111 | 111 | */ |
112 | - public function getMakeFileInstances () |
|
112 | + public function getMakeFileInstances() |
|
113 | 113 | { |
114 | - return array ( |
|
115 | - DbTable::getInstance () , |
|
116 | - Entity::getInstance () , |
|
117 | - Model::getInstance () |
|
114 | + return array( |
|
115 | + DbTable::getInstance(), |
|
116 | + Entity::getInstance(), |
|
117 | + Model::getInstance() |
|
118 | 118 | ); |
119 | 119 | } |
120 | 120 |
@@ -54,7 +54,6 @@ |
||
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @inheritDoc |
57 | - * @param string $databaseName |
|
58 | 57 | * @return \Classes\Db\DbTable[] |
59 | 58 | */ |
60 | 59 | public function getTables($schema = 0) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return array[] |
80 | 80 | */ |
81 | - public function getListColumns () |
|
81 | + public function getListColumns() |
|
82 | 82 | { |
83 | 83 | // TODO: Implement getListColumns() method. |
84 | 84 | } |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return int |
90 | 90 | */ |
91 | - public function getTotalTables () |
|
91 | + public function getTotalTables() |
|
92 | 92 | { |
93 | 93 | // TODO: Implement totalTables() method. |
94 | 94 | } |
95 | 95 | |
96 | - public function getSequence ( $table , $column ) |
|
96 | + public function getSequence($table, $column) |
|
97 | 97 | { |
98 | 98 | // TODO: Implement getSequence() method. |
99 | 99 | } |
100 | 100 | |
101 | - public function getListConstrant () |
|
101 | + public function getListConstrant() |
|
102 | 102 | { |
103 | 103 | // TODO: Implement getListConstrant() method. |
104 | 104 | } |
@@ -71,7 +71,6 @@ discard block |
||
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 | */ |
@@ -238,7 +237,7 @@ discard block |
||
238 | 237 | /** |
239 | 238 | * Retorna o Nome da Sequence da tabela |
240 | 239 | * |
241 | - * @param $table |
|
240 | + * @param string $table |
|
242 | 241 | * @param $column |
243 | 242 | * |
244 | 243 | * @return string |
@@ -247,7 +247,7 @@ |
||
247 | 247 | { |
248 | 248 | $pdo = $this->getPDO (); |
249 | 249 | $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$table', '$column');" ) |
250 | - ->fetchColumn (); |
|
250 | + ->fetchColumn (); |
|
251 | 251 | |
252 | 252 | if ( $return1 ) |
253 | 253 | { |
@@ -27,43 +27,43 @@ 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 $dataTypes = array ( |
|
32 | + protected $dataTypes = array( |
|
33 | 33 | /* Numeric Types */ |
34 | - 'smallint' => 'int' , |
|
35 | - 'integer' => 'int' , |
|
36 | - 'bigint' => 'float' , |
|
37 | - 'decimal' => 'float' , |
|
38 | - 'numeric' => 'float' , |
|
39 | - 'real' => 'float' , |
|
40 | - 'double precision' => 'float' , |
|
41 | - 'serial' => 'int' , |
|
42 | - 'bigserial' => 'float' , |
|
34 | + 'smallint' => 'int', |
|
35 | + 'integer' => 'int', |
|
36 | + 'bigint' => 'float', |
|
37 | + 'decimal' => 'float', |
|
38 | + 'numeric' => 'float', |
|
39 | + 'real' => 'float', |
|
40 | + 'double precision' => 'float', |
|
41 | + 'serial' => 'int', |
|
42 | + 'bigserial' => 'float', |
|
43 | 43 | /* Monetary Types */ |
44 | - 'money' => 'float' , |
|
44 | + 'money' => 'float', |
|
45 | 45 | /* Character Types */ |
46 | - 'character varyin' => 'string' , |
|
47 | - 'varchar' => 'string' , |
|
48 | - 'character' => 'string' , |
|
49 | - 'char' => 'string' , |
|
50 | - 'text' => 'string' , |
|
46 | + 'character varyin' => 'string', |
|
47 | + 'varchar' => 'string', |
|
48 | + 'character' => 'string', |
|
49 | + 'char' => 'string', |
|
50 | + 'text' => 'string', |
|
51 | 51 | /* Binary Data Types */ |
52 | - 'bytea' => 'string' , |
|
52 | + 'bytea' => 'string', |
|
53 | 53 | /* Date/Time Types */ |
54 | - 'datatime' => 'date' , |
|
55 | - 'date' => 'date' , |
|
54 | + 'datatime' => 'date', |
|
55 | + 'date' => 'date', |
|
56 | 56 | |
57 | 57 | /* Boolean Type */ |
58 | 58 | 'boolean' => 'boolean' |
59 | 59 | ); |
60 | 60 | |
61 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
61 | + public function __construct(AbstractAdapter $adapterConfig) |
|
62 | 62 | { |
63 | - parent::__construct ( $adapterConfig ); |
|
64 | - if ( $adapterConfig->hasSchemas () ) |
|
63 | + parent::__construct($adapterConfig); |
|
64 | + if ($adapterConfig->hasSchemas()) |
|
65 | 65 | { |
66 | - $this->schema = $adapterConfig->getSchemas (); |
|
66 | + $this->schema = $adapterConfig->getSchemas(); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return string[] |
77 | 77 | */ |
78 | - public function getListNameTable () |
|
78 | + public function getListNameTable() |
|
79 | 79 | { |
80 | - if ( empty( $this->tableList ) ) |
|
80 | + if (empty($this->tableList)) |
|
81 | 81 | { |
82 | - $strSchema = implode ( "', '" , $this->schema ); |
|
82 | + $strSchema = implode("', '", $this->schema); |
|
83 | 83 | |
84 | - $this->tableList = $this->getPDO ()->query ( |
|
84 | + $this->tableList = $this->getPDO()->query( |
|
85 | 85 | "SELECT table_schema, table_name |
86 | 86 | FROM information_schema.tables |
87 | 87 | WHERE |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | table_schema, |
92 | 92 | table_name |
93 | 93 | ASC" |
94 | - )->fetchAll (); |
|
94 | + )->fetchAll(); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return $this->tableList; |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public function getListColumns () |
|
105 | + public function getListColumns() |
|
106 | 106 | { |
107 | - $strSchema = implode ( "', '" , $this->schema ); |
|
107 | + $strSchema = implode("', '", $this->schema); |
|
108 | 108 | |
109 | - return $this->getPDO ()->query ( |
|
109 | + return $this->getPDO()->query( |
|
110 | 110 | "SELECT distinct |
111 | 111 | c.table_schema, |
112 | 112 | c.table_name, |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | ON st.table_name=c.table_name and st.table_type = 'BASE TABLE' |
121 | 121 | and c.table_schema IN ('$strSchema') |
122 | 122 | order by c.table_name asc" |
123 | - )->fetchAll ( \PDO::FETCH_ASSOC ); |
|
123 | + )->fetchAll(\PDO::FETCH_ASSOC); |
|
124 | 124 | } |
125 | 125 | |
126 | - public function getListConstrant () |
|
126 | + public function getListConstrant() |
|
127 | 127 | { |
128 | - $strSchema = implode ( "', '" , $this->schema ); |
|
128 | + $strSchema = implode("', '", $this->schema); |
|
129 | 129 | |
130 | - return $this->getPDO ()->query ( |
|
130 | + return $this->getPDO()->query( |
|
131 | 131 | "SELECT distinct |
132 | 132 | tc.constraint_type, |
133 | 133 | tc.constraint_name, |
@@ -147,53 +147,53 @@ discard block |
||
147 | 147 | ON tc.constraint_name = ccu.constraint_name |
148 | 148 | AND tc.constraint_schema = ccu.constraint_schema |
149 | 149 | ORDER by tc.table_schema" |
150 | - )->fetchAll ( \PDO::FETCH_ASSOC ); |
|
150 | + )->fetchAll(\PDO::FETCH_ASSOC); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @inheritDoc |
155 | 155 | */ |
156 | - public function parseForeignKeys () |
|
156 | + public function parseForeignKeys() |
|
157 | 157 | { |
158 | - foreach ( $this->getListConstrant () as $constrant ) |
|
158 | + foreach ($this->getListConstrant() as $constrant) |
|
159 | 159 | { |
160 | 160 | |
161 | - if ( $constrant[ 'constraint_type' ] == "FOREIGN KEY" |
|
162 | - or $constrant[ 'constraint_type' ] == "PRIMARY KEY" |
|
161 | + if ($constrant['constraint_type'] == "FOREIGN KEY" |
|
162 | + or $constrant['constraint_type'] == "PRIMARY KEY" |
|
163 | 163 | ) |
164 | 164 | { |
165 | - $schema = $constrant[ 'table_schema' ]; |
|
166 | - $key = $constrant [ 'table_name' ]; |
|
167 | - if ( isset( $this->objDbTables[ $schema ][ $key ] ) ) |
|
165 | + $schema = $constrant['table_schema']; |
|
166 | + $key = $constrant ['table_name']; |
|
167 | + if (isset($this->objDbTables[$schema][$key])) |
|
168 | 168 | { |
169 | - $column = $this->objDbTables[ $schema ][ $key ]->getColumn ( $constrant[ "column_name" ] ); |
|
170 | - if ( $column ) |
|
169 | + $column = $this->objDbTables[$schema][$key]->getColumn($constrant["column_name"]); |
|
170 | + if ($column) |
|
171 | 171 | { |
172 | 172 | $objConstrant = new Constrant(); |
173 | - $objConstrant->populate ( |
|
174 | - array ( |
|
175 | - 'constrant' => $constrant[ 'constraint_name' ] , |
|
176 | - 'schema' => $constrant[ 'foreign_schema' ] , |
|
177 | - 'table' => $constrant[ 'foreign_table' ] , |
|
178 | - 'column' => $constrant[ 'foreign_column' ] |
|
173 | + $objConstrant->populate( |
|
174 | + array( |
|
175 | + 'constrant' => $constrant['constraint_name'], |
|
176 | + 'schema' => $constrant['foreign_schema'], |
|
177 | + 'table' => $constrant['foreign_table'], |
|
178 | + 'column' => $constrant['foreign_column'] |
|
179 | 179 | ) |
180 | 180 | ); |
181 | 181 | |
182 | 182 | |
183 | - switch ( $constrant[ 'constraint_type' ] ) |
|
183 | + switch ($constrant['constraint_type']) |
|
184 | 184 | { |
185 | 185 | case "FOREIGN KEY": |
186 | 186 | { |
187 | - $column->addRefFk ( $objConstrant ); |
|
187 | + $column->addRefFk($objConstrant); |
|
188 | 188 | break; |
189 | 189 | } |
190 | 190 | case"PRIMARY KEY": |
191 | 191 | { |
192 | - $column->setPrimaryKey ( $objConstrant ); |
|
193 | - $column->setSequence ( |
|
194 | - $this->getSequence ( |
|
195 | - $schema . '.' . $key , |
|
196 | - $constrant[ "column_name" ] |
|
192 | + $column->setPrimaryKey($objConstrant); |
|
193 | + $column->setSequence( |
|
194 | + $this->getSequence( |
|
195 | + $schema . '.' . $key, |
|
196 | + $constrant["column_name"] |
|
197 | 197 | ) |
198 | 198 | ); |
199 | 199 | |
@@ -202,33 +202,33 @@ discard block |
||
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
205 | - unset( $key , $column ); |
|
205 | + unset($key, $column); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( $constrant[ 'constraint_type' ] == "FOREIGN KEY" ) |
|
208 | + if ($constrant['constraint_type'] == "FOREIGN KEY") |
|
209 | 209 | { |
210 | - $schema = $constrant[ 'foreign_schema' ]; |
|
211 | - $key = $constrant [ 'foreign_table' ]; |
|
212 | - if ( isset( $this->objDbTables[ $schema ][ $key ] ) ) |
|
210 | + $schema = $constrant['foreign_schema']; |
|
211 | + $key = $constrant ['foreign_table']; |
|
212 | + if (isset($this->objDbTables[$schema][$key])) |
|
213 | 213 | { |
214 | - $column = $this->objDbTables[ $schema ][ $key ]->getColumn ( $constrant[ "foreign_column" ] ); |
|
214 | + $column = $this->objDbTables[$schema][$key]->getColumn($constrant["foreign_column"]); |
|
215 | 215 | |
216 | - if ( $column ) |
|
216 | + if ($column) |
|
217 | 217 | { |
218 | 218 | $objConstrantDependence = new Constrant(); |
219 | - $objConstrantDependence->populate ( |
|
220 | - array ( |
|
221 | - 'constrant' => $constrant[ 'constraint_name' ] , |
|
222 | - 'schema' => $constrant[ 'table_schema' ] , |
|
223 | - 'table' => $constrant[ 'table_name' ] , |
|
224 | - 'column' => $constrant[ 'column_name' ] |
|
219 | + $objConstrantDependence->populate( |
|
220 | + array( |
|
221 | + 'constrant' => $constrant['constraint_name'], |
|
222 | + 'schema' => $constrant['table_schema'], |
|
223 | + 'table' => $constrant['table_name'], |
|
224 | + 'column' => $constrant['column_name'] |
|
225 | 225 | ) |
226 | 226 | ); |
227 | 227 | |
228 | - $column->addDependece ( $objConstrantDependence ); |
|
228 | + $column->addDependece($objConstrantDependence); |
|
229 | 229 | } |
230 | 230 | } |
231 | - unset( $key , $column ); |
|
231 | + unset($key, $column); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - public function getSequence ( $table , $column ) |
|
246 | + public function getSequence($table, $column) |
|
247 | 247 | { |
248 | - $pdo = $this->getPDO (); |
|
249 | - $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$table', '$column');" ) |
|
250 | - ->fetchColumn (); |
|
248 | + $pdo = $this->getPDO(); |
|
249 | + $return1 = $pdo->query("SELECT pg_get_serial_sequence('$table', '$column');") |
|
250 | + ->fetchColumn(); |
|
251 | 251 | |
252 | - if ( $return1 ) |
|
252 | + if ($return1) |
|
253 | 253 | { |
254 | 254 | return $return1; |
255 | 255 | } |
256 | 256 | |
257 | - $dtbase = explode ( '.' , $table );; |
|
257 | + $dtbase = explode('.', $table); ; |
|
258 | 258 | |
259 | - $stmt = $pdo->prepare ( |
|
259 | + $stmt = $pdo->prepare( |
|
260 | 260 | "SELECT adsrc FROM pg_attrdef AS att |
261 | 261 | INNER JOIN pg_class AS c |
262 | 262 | ON adrelid = c.oid AND att.adnum=1 AND c.relname = ? |
@@ -264,19 +264,19 @@ discard block |
||
264 | 264 | ON n.oid = c.relnamespace and n.nspname=?" |
265 | 265 | ); |
266 | 266 | |
267 | - $schema = isset( $dtbase[ 1 ] ) ? $dtbase[ 1 ] : 'public'; |
|
267 | + $schema = isset($dtbase[1]) ? $dtbase[1] : 'public'; |
|
268 | 268 | |
269 | - $stmt->bindParam ( 1 , $schema ); |
|
270 | - $stmt->bindParam ( 2 , $dtbase[ 0 ] ); |
|
271 | - $stmt->execute (); |
|
272 | - $return2 = $stmt->fetchColumn (); |
|
273 | - if ( $return2 ) |
|
269 | + $stmt->bindParam(1, $schema); |
|
270 | + $stmt->bindParam(2, $dtbase[0]); |
|
271 | + $stmt->execute(); |
|
272 | + $return2 = $stmt->fetchColumn(); |
|
273 | + if ($return2) |
|
274 | 274 | { |
275 | - return preg_filter ( |
|
276 | - array ( |
|
277 | - '/nextval\(\'/' , |
|
275 | + return preg_filter( |
|
276 | + array( |
|
277 | + '/nextval\(\'/', |
|
278 | 278 | '/\'::regclass\)/' |
279 | - ) , '' , $return2 |
|
279 | + ), '', $return2 |
|
280 | 280 | ); |
281 | 281 | } |
282 | 282 | |
@@ -285,42 +285,42 @@ discard block |
||
285 | 285 | /** |
286 | 286 | * @inheritDoc |
287 | 287 | */ |
288 | - public function parseTables () |
|
288 | + public function parseTables() |
|
289 | 289 | { |
290 | - if ( ! empty( $this->objDbTables ) ) |
|
290 | + if ( ! empty($this->objDbTables)) |
|
291 | 291 | { |
292 | 292 | return $this->objDbTables; |
293 | 293 | } |
294 | 294 | |
295 | - foreach ( $this->getListColumns () as $table ) |
|
295 | + foreach ($this->getListColumns() as $table) |
|
296 | 296 | { |
297 | - $schema = $table[ 'table_schema' ]; |
|
298 | - $key = $table [ 'table_name' ]; |
|
299 | - if ( ! isset( $this->objDbTables[ $schema ][ $key ] ) ) |
|
297 | + $schema = $table['table_schema']; |
|
298 | + $key = $table ['table_name']; |
|
299 | + if ( ! isset($this->objDbTables[$schema][$key])) |
|
300 | 300 | { |
301 | - $this->objDbTables[ $schema ][ $key ] = new DbTable(); |
|
302 | - $this->objDbTables[ $schema ][ $key ]->populate ( |
|
303 | - array ( |
|
304 | - 'table' => $table [ 'table_name' ] , |
|
305 | - 'schema' => $table[ 'table_schema' ] , |
|
301 | + $this->objDbTables[$schema][$key] = new DbTable(); |
|
302 | + $this->objDbTables[$schema][$key]->populate( |
|
303 | + array( |
|
304 | + 'table' => $table ['table_name'], |
|
305 | + 'schema' => $table['table_schema'], |
|
306 | 306 | 'database' => $this->database |
307 | 307 | ) |
308 | 308 | ); |
309 | 309 | } |
310 | 310 | |
311 | 311 | $column = new Column(); |
312 | - $column->populate ( |
|
313 | - array ( |
|
314 | - 'name' => $table [ 'column_name' ] , |
|
315 | - 'type' => $this->convertTypeToPhp ( $table[ 'data_type' ] ) , |
|
316 | - 'nullable' => ( $table[ 'is_nullable' ] == 'YES' ) , |
|
317 | - 'max_length' => $table[ 'max_length' ] |
|
312 | + $column->populate( |
|
313 | + array( |
|
314 | + 'name' => $table ['column_name'], |
|
315 | + 'type' => $this->convertTypeToPhp($table['data_type']), |
|
316 | + 'nullable' => ($table['is_nullable'] == 'YES'), |
|
317 | + 'max_length' => $table['max_length'] |
|
318 | 318 | ) |
319 | 319 | ); |
320 | 320 | |
321 | - $this->objDbTables[ $schema ][ $key ]->addColumn ( $column ); |
|
322 | - $this->objDbTables[ $schema ][ $key ]->setNamespace ( |
|
323 | - $this->config->createClassNamespace ( $this->objDbTables[ $schema ][ $key ] ) |
|
321 | + $this->objDbTables[$schema][$key]->addColumn($column); |
|
322 | + $this->objDbTables[$schema][$key]->setNamespace( |
|
323 | + $this->config->createClassNamespace($this->objDbTables[$schema][$key]) |
|
324 | 324 | ); |
325 | 325 | } |
326 | 326 | |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | * @inheritDoc |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - public function getPDOString () |
|
333 | + public function getPDOString() |
|
334 | 334 | { |
335 | - return sprintf ( |
|
336 | - "pgsql:host=%s;port=%s;dbname=%s" , |
|
337 | - $this->host , |
|
338 | - $this->port , |
|
335 | + return sprintf( |
|
336 | + "pgsql:host=%s;port=%s;dbname=%s", |
|
337 | + $this->host, |
|
338 | + $this->port, |
|
339 | 339 | $this->database |
340 | 340 | |
341 | 341 | ); |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * @inheritDoc |
346 | 346 | * @return string |
347 | 347 | */ |
348 | - public function getPDOSocketString () |
|
348 | + public function getPDOSocketString() |
|
349 | 349 | { |
350 | - return sprintf ( |
|
351 | - "pgsql:unix_socket=%s;dbname=%s" , |
|
352 | - $this->socket , |
|
350 | + return sprintf( |
|
351 | + "pgsql:unix_socket=%s;dbname=%s", |
|
352 | + $this->socket, |
|
353 | 353 | $this->database |
354 | 354 | |
355 | 355 | ); |
@@ -360,19 +360,19 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return int |
362 | 362 | */ |
363 | - public function getTotalTables () |
|
363 | + public function getTotalTables() |
|
364 | 364 | { |
365 | - if ( empty( $this->totalTables ) ) |
|
365 | + if (empty($this->totalTables)) |
|
366 | 366 | { |
367 | - $strSchema = implode ( "', '" , $this->schema ); |
|
367 | + $strSchema = implode("', '", $this->schema); |
|
368 | 368 | |
369 | - $this->totalTables = $this->getPDO ()->query ( |
|
369 | + $this->totalTables = $this->getPDO()->query( |
|
370 | 370 | "SELECT COUNT(table_name) AS total |
371 | 371 | FROM information_schema.tables |
372 | 372 | WHERE |
373 | 373 | table_type = 'BASE TABLE' |
374 | 374 | AND table_schema IN ( '" . $strSchema . "' )" |
375 | - )->fetchColumn (); |
|
375 | + )->fetchColumn(); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | return (int) $this->totalTables; |
@@ -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,7 +11,7 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * @author Pedro Alarcao <[email protected]> |
13 | 13 | */ |
14 | - public function __construct () |
|
14 | + public function __construct() |
|
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @var \Classes\Db\Column[] |
35 | 35 | */ |
36 | - private $columns = array (); |
|
36 | + private $columns = array(); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @var string |
@@ -43,25 +43,25 @@ discard block |
||
43 | 43 | /** |
44 | 44 | * @type \Classes\Db\Column[] |
45 | 45 | */ |
46 | - private $primarykeys = array (); |
|
46 | + private $primarykeys = array(); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @type \Classes\Db\Column[] |
50 | 50 | */ |
51 | - private $foreingkeys = array (); |
|
51 | + private $foreingkeys = array(); |
|
52 | 52 | |
53 | - private $dependence = array (); |
|
53 | + private $dependence = array(); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @type string[] |
57 | 57 | */ |
58 | - private $sequence = array (); |
|
58 | + private $sequence = array(); |
|
59 | 59 | |
60 | - public function populate ( $array ) |
|
60 | + public function populate($array) |
|
61 | 61 | { |
62 | - $this->name = $array[ 'table' ]; |
|
63 | - $this->schema = isset( $array[ 'schema' ] ) ? $array[ 'schema' ] : null; |
|
64 | - $this->database = $array[ 'database' ]; |
|
62 | + $this->name = $array['table']; |
|
63 | + $this->schema = isset($array['schema']) ? $array['schema'] : null; |
|
64 | + $this->database = $array['database']; |
|
65 | 65 | |
66 | 66 | return $this; |
67 | 67 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * @param \Classes\Db\Column $column |
71 | 71 | */ |
72 | - public function addColumn ( Column $column ) |
|
72 | + public function addColumn(Column $column) |
|
73 | 73 | { |
74 | - $this->columns[ $column->getName () ] = $column; |
|
74 | + $this->columns[$column->getName()] = $column; |
|
75 | 75 | |
76 | 76 | return $this; |
77 | 77 | } |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return \Classes\Db\Column |
83 | 83 | */ |
84 | - public function getColumn ( $columnName ) |
|
84 | + public function getColumn($columnName) |
|
85 | 85 | { |
86 | - if ( isset( $this->columns[ $columnName ] ) ) |
|
86 | + if (isset($this->columns[$columnName])) |
|
87 | 87 | { |
88 | - return $this->columns[ $columnName ]; |
|
88 | + return $this->columns[$columnName]; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return; |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @return \Classes\Db\Column[] |
96 | 96 | */ |
97 | - public function getPrimaryKeys () |
|
97 | + public function getPrimaryKeys() |
|
98 | 98 | { |
99 | - if ( empty ( $this->primarykeys ) ) |
|
99 | + if (empty ($this->primarykeys)) |
|
100 | 100 | { |
101 | - $this->primarykeys = array_filter ( $this->columns , function ( $column ){ return $column->isPrimaryKey (); } ); |
|
101 | + $this->primarykeys = array_filter($this->columns, function($column) { return $column->isPrimaryKey(); } ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $this->primarykeys; |
@@ -107,25 +107,25 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - public function hasPrimaryKey () |
|
110 | + public function hasPrimaryKey() |
|
111 | 111 | { |
112 | - if ( empty ( $this->sequence ) ) |
|
112 | + if (empty ($this->sequence)) |
|
113 | 113 | { |
114 | - $this->getPrimaryKeys (); |
|
114 | + $this->getPrimaryKeys(); |
|
115 | 115 | } |
116 | 116 | |
117 | - return ! empty ( $this->sequence ); |
|
117 | + return ! empty ($this->sequence); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @return \Classes\Db\Column[] |
122 | 122 | */ |
123 | - public function getForeingkeys () |
|
123 | + public function getForeingkeys() |
|
124 | 124 | { |
125 | 125 | |
126 | - if ( empty ( $this->foreingkeys ) ) |
|
126 | + if (empty ($this->foreingkeys)) |
|
127 | 127 | { |
128 | - $this->foreingkeys = array_filter ( $this->columns , function ( $column ){ return $column->isForeingkey (); } ); |
|
128 | + $this->foreingkeys = array_filter($this->columns, function($column) { return $column->isForeingkey(); } ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | return $this->foreingkeys; |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * @return \Classes\Db\Column[] |
137 | 137 | */ |
138 | - public function getDependences () |
|
138 | + public function getDependences() |
|
139 | 139 | { |
140 | - if ( empty ( $this->dependence ) ) |
|
140 | + if (empty ($this->dependence)) |
|
141 | 141 | { |
142 | - $this->dependence = array_filter ( $this->columns , function ( $column ){ return $column->hasDependence (); } ); |
|
142 | + $this->dependence = array_filter($this->columns, function($column) { return $column->hasDependence(); } ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $this->dependence; |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * @return string[] |
150 | 150 | */ |
151 | - public function getSequences () |
|
151 | + public function getSequences() |
|
152 | 152 | { |
153 | - if ( empty ( $this->sequence ) ) |
|
153 | + if (empty ($this->sequence)) |
|
154 | 154 | { |
155 | - $this->sequence = array_filter ( $this->columns , function ( $column ){ return $column->hasSequence (); } ); |
|
155 | + $this->sequence = array_filter($this->columns, function($column) { return $column->hasSequence(); } ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return $this->sequence; |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * @return bool |
163 | 163 | */ |
164 | - public function hasSequences () |
|
164 | + public function hasSequences() |
|
165 | 165 | { |
166 | - if ( empty ( $this->sequence ) ) |
|
166 | + if (empty ($this->sequence)) |
|
167 | 167 | { |
168 | - $this->getSequences (); |
|
168 | + $this->getSequences(); |
|
169 | 169 | } |
170 | 170 | |
171 | - return ! empty ( $this->sequence ); |
|
171 | + return ! empty ($this->sequence); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
175 | 175 | * @return \Classes\Db\Column[] |
176 | 176 | */ |
177 | - public function getColumns () |
|
177 | + public function getColumns() |
|
178 | 178 | { |
179 | 179 | return $this->columns; |
180 | 180 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | /** |
183 | 183 | * @return string |
184 | 184 | */ |
185 | - public function getName () |
|
185 | + public function getName() |
|
186 | 186 | { |
187 | 187 | return $this->name; |
188 | 188 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | /** |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function getSchema () |
|
193 | + public function getSchema() |
|
194 | 194 | { |
195 | 195 | return $this->schema; |
196 | 196 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | /** |
199 | 199 | * @return bool |
200 | 200 | */ |
201 | - public function hasSchema () |
|
201 | + public function hasSchema() |
|
202 | 202 | { |
203 | 203 | return (bool) $this->schema; |
204 | 204 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | /** |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - public function getDatabase () |
|
209 | + public function getDatabase() |
|
210 | 210 | { |
211 | 211 | return $this->database; |
212 | 212 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | /** |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public function getNamespace () |
|
217 | + public function getNamespace() |
|
218 | 218 | { |
219 | 219 | return $this->namespace; |
220 | 220 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * @param string $Namespace |
224 | 224 | */ |
225 | - public function setNamespace ( $namespace ) |
|
225 | + public function setNamespace($namespace) |
|
226 | 226 | { |
227 | 227 | $this->namespace = $namespace; |
228 | 228 | } |
@@ -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 | - 'config-env' => '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 | + 'config-env' => '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 | - $this->baseLocation = dirname ( $basePath ); |
|
55 | + $this->baseLocation = dirname($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[ 'config-env' ] . '.ini' , |
|
78 | - $this->getParsedTplContents ( $this->template , $this->argv ) |
|
75 | + self::makeDir($path); |
|
76 | + self::makeSourcer( |
|
77 | + $path . DIRECTORY_SEPARATOR . $this->argv['config-env'] . '.ini', |
|
78 | + $this->getParsedTplContents($this->template, $this->argv) |
|
79 | 79 | ); |
80 | 80 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
81 | 81 | } |
@@ -46,6 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Analisa os caminhos das pastas base |
49 | + * @param string $basePath |
|
49 | 50 | */ |
50 | 51 | public function parseLocation ( $basePath ) |
51 | 52 | { |
@@ -175,6 +176,9 @@ discard block |
||
175 | 176 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
176 | 177 | } |
177 | 178 | |
179 | + /** |
|
180 | + * @param integer $countFiles |
|
181 | + */ |
|
178 | 182 | private function reportProcess ( $countFiles ) |
179 | 183 | { |
180 | 184 | if ( $this->config->isStatusEnabled () ) |
@@ -194,7 +198,7 @@ discard block |
||
194 | 198 | /** |
195 | 199 | * Instancia os Modulos de diretorios e tampletes |
196 | 200 | * |
197 | - * @return AbstractAdapter[] |
|
201 | + * @return AdapterConfig\AbstractAdapter[] |
|
198 | 202 | */ |
199 | 203 | public function factoryMakerFile () |
200 | 204 | { |
@@ -225,6 +229,7 @@ discard block |
||
225 | 229 | * parse a tpl file and return the result |
226 | 230 | * |
227 | 231 | * @param String $tplFile |
232 | + * @param AdapterConfig\AbstractAdapter $objMakeFile |
|
228 | 233 | * |
229 | 234 | * @return String |
230 | 235 | */ |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @type string[] |
20 | 20 | */ |
21 | - public $location = array (); |
|
21 | + public $location = array(); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * caminho de pastas Base |
@@ -37,156 +37,156 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private $driver; |
39 | 39 | |
40 | - public function __construct ( Config $config ) |
|
40 | + public function __construct(Config $config) |
|
41 | 41 | { |
42 | - $this->config = $config->getAdapterConfig (); |
|
43 | - $this->driver = $config->getAdapterDriver (); |
|
44 | - $this->parseLocation ( $config->_basePath ); |
|
42 | + $this->config = $config->getAdapterConfig(); |
|
43 | + $this->driver = $config->getAdapterDriver(); |
|
44 | + $this->parseLocation($config->_basePath); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Analisa os caminhos das pastas base |
49 | 49 | */ |
50 | - public function parseLocation ( $basePath ) |
|
50 | + public function parseLocation($basePath) |
|
51 | 51 | { |
52 | 52 | |
53 | - $arrBase = array ( |
|
54 | - $basePath , |
|
53 | + $arrBase = array( |
|
54 | + $basePath, |
|
55 | 55 | $this->config->path |
56 | 56 | ); |
57 | 57 | |
58 | - $this->baseLocation = implode ( DIRECTORY_SEPARATOR , array_filter ( $arrBase ) ); |
|
58 | + $this->baseLocation = implode(DIRECTORY_SEPARATOR, array_filter($arrBase)); |
|
59 | 59 | |
60 | 60 | # pasta com nome do driver do banco |
61 | 61 | $driverBase = ''; |
62 | - if ( $this->config->{"folder-database"} ) |
|
62 | + if ($this->config->{"folder-database"} ) |
|
63 | 63 | { |
64 | - $classDriver = explode ( '\\' , get_class ( $this->driver ) ); |
|
65 | - $driverBase = end ( $classDriver ); |
|
64 | + $classDriver = explode('\\', get_class($this->driver)); |
|
65 | + $driverBase = end($classDriver); |
|
66 | 66 | } |
67 | 67 | |
68 | - if ( $this->config->hasSchemas () ) |
|
68 | + if ($this->config->hasSchemas()) |
|
69 | 69 | { |
70 | 70 | |
71 | - $schemas = $this->config->getSchemas (); |
|
72 | - foreach ( $schemas as $schema ) |
|
71 | + $schemas = $this->config->getSchemas(); |
|
72 | + foreach ($schemas as $schema) |
|
73 | 73 | { |
74 | - $arrUrl = array ( |
|
75 | - $this->baseLocation , |
|
76 | - $driverBase , |
|
77 | - $this->getClassName ( $schema ) |
|
74 | + $arrUrl = array( |
|
75 | + $this->baseLocation, |
|
76 | + $driverBase, |
|
77 | + $this->getClassName($schema) |
|
78 | 78 | ); |
79 | 79 | |
80 | - $this->location[ $schema ] = implode ( DIRECTORY_SEPARATOR , array_filter ( $arrUrl ) ); |
|
81 | - unset( $arrUrl ); |
|
80 | + $this->location[$schema] = implode(DIRECTORY_SEPARATOR, array_filter($arrUrl)); |
|
81 | + unset($arrUrl); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | } else |
86 | 86 | { |
87 | - $baseLocation = implode ( |
|
88 | - DIRECTORY_SEPARATOR , array_filter ( array ( |
|
89 | - $this->baseLocation , |
|
90 | - $driverBase , |
|
91 | - $this->getClassName ( $this->getConfig()->getDatabase () ) |
|
87 | + $baseLocation = implode( |
|
88 | + DIRECTORY_SEPARATOR, array_filter(array( |
|
89 | + $this->baseLocation, |
|
90 | + $driverBase, |
|
91 | + $this->getClassName($this->getConfig()->getDatabase()) |
|
92 | 92 | ) |
93 | 93 | ) |
94 | 94 | ); |
95 | - $this->location = array ( $baseLocation ); |
|
95 | + $this->location = array($baseLocation); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return AdapterConfig\AbstractAdapter |
101 | 101 | */ |
102 | - public function getConfig () |
|
102 | + public function getConfig() |
|
103 | 103 | { |
104 | 104 | return $this->config; |
105 | 105 | } |
106 | 106 | |
107 | 107 | /* Get current time */ |
108 | - public function startTime () |
|
108 | + public function startTime() |
|
109 | 109 | { |
110 | 110 | echo "Starting..\n"; |
111 | - $this->startTime = microtime ( true ); |
|
111 | + $this->startTime = microtime(true); |
|
112 | 112 | } |
113 | 113 | |
114 | - private function getRunTime () |
|
114 | + private function getRunTime() |
|
115 | 115 | { |
116 | - return round ( ( microtime ( true ) - $this->startTime ) , 3 ); |
|
116 | + return round((microtime(true) - $this->startTime), 3); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Executa o Make, criando arquivos e Diretorios |
121 | 121 | */ |
122 | - public function run () |
|
122 | + public function run() |
|
123 | 123 | { |
124 | - $this->startTime (); |
|
125 | - $this->driver->runDatabase (); |
|
126 | - $max = $this->driver->getTotalTables () * count ( $this->factoryMakerFile () ); |
|
124 | + $this->startTime(); |
|
125 | + $this->driver->runDatabase(); |
|
126 | + $max = $this->driver->getTotalTables() * count($this->factoryMakerFile()); |
|
127 | 127 | $cur = 0; |
128 | 128 | |
129 | 129 | |
130 | - foreach ( $this->location as $schema => $location ) |
|
130 | + foreach ($this->location as $schema => $location) |
|
131 | 131 | { |
132 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) |
|
132 | + foreach ($this->factoryMakerFile() as $objMakeFile) |
|
133 | 133 | { |
134 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
135 | - self::makeDir ( $path ); |
|
134 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
135 | + self::makeDir($path); |
|
136 | 136 | |
137 | - if ( $objMakeFile->getParentFileTpl () != '' ) |
|
137 | + if ($objMakeFile->getParentFileTpl() != '') |
|
138 | 138 | { |
139 | 139 | $fileAbstract = $this->baseLocation |
140 | 140 | . DIRECTORY_SEPARATOR |
141 | - . $objMakeFile->getParentClass () . '.php'; |
|
141 | + . $objMakeFile->getParentClass() . '.php'; |
|
142 | 142 | |
143 | - $tplAbstract = $this->getParsedTplContents ( $objMakeFile->getParentFileTpl () ); |
|
144 | - self::makeSourcer ( $fileAbstract , $tplAbstract, $objMakeFile->isOverwrite() ); |
|
145 | - unset( $fileAbstract , $tplAbstract ); |
|
143 | + $tplAbstract = $this->getParsedTplContents($objMakeFile->getParentFileTpl()); |
|
144 | + self::makeSourcer($fileAbstract, $tplAbstract, $objMakeFile->isOverwrite()); |
|
145 | + unset($fileAbstract, $tplAbstract); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | foreach ( |
149 | - $this->driver->getTables ( $schema ) as $key => $objTables |
|
149 | + $this->driver->getTables($schema) as $key => $objTables |
|
150 | 150 | ) |
151 | 151 | { |
152 | - $total = ceil ($cur / $max) * 100; |
|
153 | - printf ( "\r Creating: %6.2f%%" , $total ); |
|
154 | - $cur ++; |
|
152 | + $total = ceil($cur / $max) * 100; |
|
153 | + printf("\r Creating: %6.2f%%", $total); |
|
154 | + $cur++; |
|
155 | 155 | |
156 | 156 | $file = $path |
157 | 157 | . DIRECTORY_SEPARATOR |
158 | - . self::getClassName ( $objTables->getName () ) |
|
158 | + . self::getClassName($objTables->getName()) |
|
159 | 159 | . '.php'; |
160 | 160 | |
161 | 161 | |
162 | - $tpl = $this->getParsedTplContents ( |
|
163 | - $objMakeFile->getFileTpl () , |
|
164 | - $objMakeFile->parseRelation ( $this , $objTables ) |
|
165 | - , $objTables , $objMakeFile |
|
162 | + $tpl = $this->getParsedTplContents( |
|
163 | + $objMakeFile->getFileTpl(), |
|
164 | + $objMakeFile->parseRelation($this, $objTables) |
|
165 | + , $objTables, $objMakeFile |
|
166 | 166 | |
167 | 167 | ); |
168 | - self::makeSourcer ( $file , $tpl, $objMakeFile->isOverwrite() ); |
|
168 | + self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | - $this->reportProcess ( $cur ); |
|
174 | + $this->reportProcess($cur); |
|
175 | 175 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
176 | 176 | } |
177 | 177 | |
178 | - private function reportProcess ( $countFiles ) |
|
178 | + private function reportProcess($countFiles) |
|
179 | 179 | { |
180 | - if ( $this->config->isStatusEnabled () ) |
|
180 | + if ($this->config->isStatusEnabled()) |
|
181 | 181 | { |
182 | - $databases = count ( $this->location ); |
|
183 | - $countDir = $this->countDiretory (); |
|
184 | - $totalTable = $this->driver->getTotalTables (); |
|
182 | + $databases = count($this->location); |
|
183 | + $countDir = $this->countDiretory(); |
|
184 | + $totalTable = $this->driver->getTotalTables(); |
|
185 | 185 | echo "\n------"; |
186 | - printf ( "\n\r-Files generated:%s" , $countFiles ); |
|
187 | - printf ( "\n\r-Diretory generated:%s" , $databases * $countDir ); |
|
188 | - printf ( "\n\r-Scanned tables:%s" , $totalTable ); |
|
189 | - printf ( "\n\r-Execution time: %ssec" , $this->getRunTime () ); |
|
186 | + printf("\n\r-Files generated:%s", $countFiles); |
|
187 | + printf("\n\r-Diretory generated:%s", $databases * $countDir); |
|
188 | + printf("\n\r-Scanned tables:%s", $totalTable); |
|
189 | + printf("\n\r-Execution time: %ssec", $this->getRunTime()); |
|
190 | 190 | echo "\n------"; |
191 | 191 | } |
192 | 192 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return AbstractAdapter[] |
198 | 198 | */ |
199 | - public function factoryMakerFile () |
|
199 | + public function factoryMakerFile() |
|
200 | 200 | { |
201 | - return $this->config->getMakeFileInstances (); |
|
201 | + return $this->config->getMakeFileInstances(); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return int |
208 | 208 | */ |
209 | - public function countDiretory () |
|
209 | + public function countDiretory() |
|
210 | 210 | { |
211 | 211 | $dir = 0; |
212 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) |
|
212 | + foreach ($this->factoryMakerFile() as $abstractAdapter) |
|
213 | 213 | { |
214 | - if ( $abstractAdapter->hasDiretory () ) |
|
214 | + if ($abstractAdapter->hasDiretory()) |
|
215 | 215 | { |
216 | - $dir ++; |
|
216 | + $dir++; |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
@@ -228,23 +228,23 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return String |
230 | 230 | */ |
231 | - protected function getParsedTplContents ( $tplFile , $vars = array () , \Classes\Db\DbTable $objTables = null , $objMakeFile = null ) |
|
231 | + protected function getParsedTplContents($tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, $objMakeFile = null) |
|
232 | 232 | { |
233 | 233 | |
234 | - $arrUrl = array ( |
|
235 | - __DIR__ , |
|
236 | - 'templates' , |
|
237 | - $this->config->framework , |
|
234 | + $arrUrl = array( |
|
235 | + __DIR__, |
|
236 | + 'templates', |
|
237 | + $this->config->framework, |
|
238 | 238 | $tplFile |
239 | 239 | ); |
240 | 240 | |
241 | - $filePath = implode ( DIRECTORY_SEPARATOR , filter_var_array ( $arrUrl ) ); |
|
241 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
242 | 242 | |
243 | - extract ( $vars ); |
|
244 | - ob_start (); |
|
243 | + extract($vars); |
|
244 | + ob_start(); |
|
245 | 245 | require $filePath; |
246 | - $data = ob_get_contents (); |
|
247 | - ob_end_clean (); |
|
246 | + $data = ob_get_contents(); |
|
247 | + ob_end_clean(); |
|
248 | 248 | |
249 | 249 | return $data; |
250 | 250 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! ini_get ( 'short_open_tag' ) ) |
|
3 | +if ( ! ini_get('short_open_tag')) |
|
4 | 4 | { |
5 | - die( "please enable short_open_tag directive in php.ini\n" ); |
|
5 | + die("please enable short_open_tag directive in php.ini\n"); |
|
6 | 6 | } |
7 | 7 | |
8 | -if ( ! ini_get ( 'register_argc_argv' ) ) |
|
8 | +if ( ! ini_get('register_argc_argv')) |
|
9 | 9 | { |
10 | - die( "please enable register_argc_argv directive in php.ini\n" ); |
|
10 | + die("please enable register_argc_argv directive in php.ini\n"); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if (function_exists('ini_set')) { |
14 | 14 | @ini_set('display_errors', 1); |
15 | 15 | |
16 | - $memoryInBytes = function ($value) { |
|
16 | + $memoryInBytes = function($value) { |
|
17 | 17 | $unit = strtolower(substr($value, -1, 1)); |
18 | 18 | $value = (int) $value; |
19 | - switch($unit) { |
|
19 | + switch ($unit) { |
|
20 | 20 | case 'g': |
21 | 21 | $value *= 1024; |
22 | 22 | // no break (cumulative multiplier) |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | unset($memoryInBytes, $memoryLimit); |
39 | 39 | } |
40 | 40 | |
41 | -\Phar::interceptFileFuncs (); |
|
41 | +\Phar::interceptFileFuncs(); |
|
42 | 42 | |
43 | -set_include_path ( |
|
44 | - implode ( |
|
45 | - PATH_SEPARATOR , |
|
46 | - array ( |
|
47 | - realpath ( __DIR__ ) , |
|
48 | - get_include_path () , |
|
43 | +set_include_path( |
|
44 | + implode( |
|
45 | + PATH_SEPARATOR, |
|
46 | + array( |
|
47 | + realpath(__DIR__), |
|
48 | + get_include_path(), |
|
49 | 49 | ) |
50 | 50 | ) |
51 | 51 | ); |
@@ -56,43 +56,43 @@ discard block |
||
56 | 56 | |
57 | 57 | try |
58 | 58 | { |
59 | - $_path = realpath ( |
|
60 | - str_replace ( |
|
59 | + $_path = realpath( |
|
60 | + str_replace( |
|
61 | 61 | 'phar://' |
62 | - , '' , __DIR__ |
|
62 | + , '', __DIR__ |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | |
66 | - $arrValid = array ( |
|
67 | - 'version' , |
|
68 | - 'help' , |
|
69 | - 'status' , |
|
70 | - 'init' , |
|
71 | - 'config-env:' , |
|
72 | - 'config-ini:' , |
|
73 | - 'database:' , |
|
74 | - 'schema:' , |
|
75 | - 'driver:' , |
|
76 | - 'framework:' , |
|
66 | + $arrValid = array( |
|
67 | + 'version', |
|
68 | + 'help', |
|
69 | + 'status', |
|
70 | + 'init', |
|
71 | + 'config-env:', |
|
72 | + 'config-ini:', |
|
73 | + 'database:', |
|
74 | + 'schema:', |
|
75 | + 'driver:', |
|
76 | + 'framework:', |
|
77 | 77 | 'path:' |
78 | 78 | ); |
79 | 79 | |
80 | - $argv = getopt ( null, $arrValid ); |
|
80 | + $argv = getopt(null, $arrValid); |
|
81 | 81 | |
82 | - if ( array_key_exists ( 'init', $argv ) ) |
|
82 | + if (array_key_exists('init', $argv)) |
|
83 | 83 | { |
84 | - $maker = new \Classes\MakerConfigFile( $argv, $_path ); |
|
84 | + $maker = new \Classes\MakerConfigFile($argv, $_path); |
|
85 | 85 | } |
86 | 86 | else |
87 | 87 | { |
88 | - $maker = new \Classes\MakerFile( new \Classes\Config( $argv, $_path ) ); |
|
88 | + $maker = new \Classes\MakerFile(new \Classes\Config($argv, $_path)); |
|
89 | 89 | } |
90 | 90 | |
91 | - $maker->run (); |
|
91 | + $maker->run(); |
|
92 | 92 | |
93 | -} catch ( \Exception $e ) |
|
93 | +} catch (\Exception $e) |
|
94 | 94 | { |
95 | - die( $e->getMessage () ); |
|
95 | + die($e->getMessage()); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | __halt_compiler(); |
99 | 99 | \ No newline at end of file |
@@ -82,8 +82,7 @@ |
||
82 | 82 | if ( array_key_exists ( 'init', $argv ) ) |
83 | 83 | { |
84 | 84 | $maker = new \Classes\MakerConfigFile( $argv, $_path ); |
85 | - } |
|
86 | - else |
|
85 | + } else |
|
87 | 86 | { |
88 | 87 | $maker = new \Classes\MakerFile( new \Classes\Config( $argv, $_path ) ); |
89 | 88 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @type \Classes\Db\DbTable[][] |
58 | 58 | */ |
59 | - protected $objDbTables = array (); |
|
59 | + protected $objDbTables = array(); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @var AbstractAdapter |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * Popula as ForeingKeys do banco nos objetos |
73 | 73 | */ |
74 | - protected abstract function parseForeignKeys (); |
|
74 | + protected abstract function parseForeignKeys(); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * cria um Array com nome das tabelas |
78 | 78 | */ |
79 | - protected abstract function parseTables (); |
|
79 | + protected abstract function parseTables(); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * retorna o numero total de tabelas |
83 | 83 | * |
84 | 84 | * @return int |
85 | 85 | */ |
86 | - public abstract function getTotalTables (); |
|
86 | + public abstract function getTotalTables(); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Retorna o Nome da Sequence da tabela |
@@ -93,23 +93,23 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - public abstract function getSequence ( $table , $column ); |
|
96 | + public abstract function getSequence($table, $column); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @return array |
100 | 100 | */ |
101 | - public abstract function getListConstrant (); |
|
101 | + public abstract function getListConstrant(); |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @param string $str |
105 | 105 | * |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - protected function convertTypeToPhp ( $str ) |
|
108 | + protected function convertTypeToPhp($str) |
|
109 | 109 | { |
110 | - if ( isset( $this->dataTypes[ $str ] ) ) |
|
110 | + if (isset($this->dataTypes[$str])) |
|
111 | 111 | { |
112 | - return $this->dataTypes[ $str ]; |
|
112 | + return $this->dataTypes[$str]; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return 'string'; |
@@ -118,26 +118,26 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - public abstract function getPDOString (); |
|
121 | + public abstract function getPDOString(); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - public abstract function getPDOSocketString (); |
|
126 | + public abstract function getPDOSocketString(); |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Retorna um Array Assoc com a chave com nome da tabela e o valor com objeto tables |
130 | 130 | * |
131 | 131 | * @return \Classes\Db\DbTable[] |
132 | 132 | */ |
133 | - public function getTables ( $schema = 0 ) |
|
133 | + public function getTables($schema = 0) |
|
134 | 134 | { |
135 | - if ( ! isset( $this->objDbTables[ $schema ] ) ) |
|
135 | + if ( ! isset($this->objDbTables[$schema])) |
|
136 | 136 | { |
137 | - return array (); |
|
137 | + return array(); |
|
138 | 138 | } |
139 | 139 | |
140 | - return $this->objDbTables[ $schema ]; |
|
140 | + return $this->objDbTables[$schema]; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return \Classes\Db\DbTable|null |
149 | 149 | */ |
150 | - public function getTable ( $nameTable , $schema = 0 ) |
|
150 | + public function getTable($nameTable, $schema = 0) |
|
151 | 151 | { |
152 | - if ( isset( $this->objDbTables[ $schema ][ trim ( $nameTable ) ] ) ) |
|
152 | + if (isset($this->objDbTables[$schema][trim($nameTable)])) |
|
153 | 153 | { |
154 | - return $this->objDbTables[ $schema ][ trim ( $nameTable ) ]; |
|
154 | + return $this->objDbTables[$schema][trim($nameTable)]; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return null; |
@@ -162,64 +162,64 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return array[] |
164 | 164 | */ |
165 | - public abstract function getListColumns (); |
|
165 | + public abstract function getListColumns(); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Retorna um Array com nome das tabelas |
169 | 169 | * |
170 | 170 | * @return string[] |
171 | 171 | */ |
172 | - public abstract function getListNameTable (); |
|
172 | + public abstract function getListNameTable(); |
|
173 | 173 | |
174 | 174 | /** |
175 | 175 | * @param \Classes\AdapterConfig\AbstractAdapter $adapterConfig |
176 | 176 | */ |
177 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
177 | + public function __construct(AbstractAdapter $adapterConfig) |
|
178 | 178 | { |
179 | 179 | $this->config = $adapterConfig; |
180 | - $this->host = $adapterConfig->getHost (); |
|
181 | - $this->database = $adapterConfig->getDatabase (); |
|
182 | - $this->port = $adapterConfig->hasPort () ? $adapterConfig->getPort () |
|
180 | + $this->host = $adapterConfig->getHost(); |
|
181 | + $this->database = $adapterConfig->getDatabase(); |
|
182 | + $this->port = $adapterConfig->hasPort() ? $adapterConfig->getPort() |
|
183 | 183 | : $this->port; |
184 | - $this->username = $adapterConfig->getUser (); |
|
185 | - $this->password = $adapterConfig->getPassword (); |
|
186 | - $this->socket = $adapterConfig->getSocket (); |
|
184 | + $this->username = $adapterConfig->getUser(); |
|
185 | + $this->password = $adapterConfig->getPassword(); |
|
186 | + $this->socket = $adapterConfig->getSocket(); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Executa as consultas do banco de dados |
192 | 192 | */ |
193 | - public function runDatabase () |
|
193 | + public function runDatabase() |
|
194 | 194 | { |
195 | - $this->parseTables (); |
|
196 | - $this->parseForeignKeys (); |
|
195 | + $this->parseTables(); |
|
196 | + $this->parseForeignKeys(); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
200 | 200 | * |
201 | 201 | * @return \PDO |
202 | 202 | */ |
203 | - public function getPDO () |
|
203 | + public function getPDO() |
|
204 | 204 | { |
205 | - if ( is_null ( $this->_pdo ) ) |
|
205 | + if (is_null($this->_pdo)) |
|
206 | 206 | { |
207 | - if ( ! empty( $this->socket ) ) |
|
207 | + if ( ! empty($this->socket)) |
|
208 | 208 | { |
209 | - $pdoString = $this->getPDOSocketString (); |
|
209 | + $pdoString = $this->getPDOSocketString(); |
|
210 | 210 | } else |
211 | 211 | { |
212 | - $pdoString = $this->getPDOString (); |
|
212 | + $pdoString = $this->getPDOString(); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | try |
216 | 216 | { |
217 | - $this->_pdo = new \PDO ( |
|
218 | - $pdoString , $this->username , $this->password |
|
217 | + $this->_pdo = new \PDO( |
|
218 | + $pdoString, $this->username, $this->password |
|
219 | 219 | ); |
220 | - } catch ( \Exception $e ) |
|
220 | + } catch (\Exception $e) |
|
221 | 221 | { |
222 | - die ( "pdo error: " . $e->getMessage () . "\n" ); |
|
222 | + die ("pdo error: " . $e->getMessage() . "\n"); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 |