@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | class QueryBase implements QueryBaseContract |
11 | 11 | { |
12 | - use QueryStack,ColumnsProcess; |
|
12 | + use QueryStack, ColumnsProcess; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @return mixed |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $list = []; |
30 | 30 | |
31 | - foreach ($tables as $key=>$resource){ |
|
31 | + foreach ($tables as $key=>$resource) { |
|
32 | 32 | |
33 | 33 | $list[$key] = $resource[0]; |
34 | 34 | } |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | * @param array $tables |
41 | 41 | * @return ColumnsProcessContract |
42 | 42 | */ |
43 | - public function getColumns($tables=array()) |
|
43 | + public function getColumns($tables = array()) |
|
44 | 44 | { |
45 | 45 | $tableList = (count($tables)) ? $tables : $this->getTables(); |
46 | 46 | |
47 | 47 | $list = []; |
48 | 48 | |
49 | - foreach ($tableList as $table){ |
|
49 | + foreach ($tableList as $table) { |
|
50 | 50 | |
51 | - if(in_array($table,$this->getTables())){ |
|
51 | + if (in_array($table, $this->getTables())) { |
|
52 | 52 | $list[$table] = $this->showColumnsFrom($table); |
53 | 53 | } |
54 | 54 | } |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | * @param $name |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - protected function getNullableValue($nullable,$name) |
|
13 | + protected function getNullableValue($nullable, $name) |
|
14 | 14 | { |
15 | - $nullableValue=''; |
|
15 | + $nullableValue = ''; |
|
16 | 16 | |
17 | - if(isset($nullable[$name])){ |
|
18 | - if($nullable[$name]===false){ |
|
19 | - $nullableValue='NOT NULL'; |
|
17 | + if (isset($nullable[$name])) { |
|
18 | + if ($nullable[$name]===false) { |
|
19 | + $nullableValue = 'NOT NULL'; |
|
20 | 20 | } |
21 | - else{ |
|
22 | - $nullableValue='NULL'; |
|
21 | + else { |
|
22 | + $nullableValue = 'NULL'; |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | protected function getValueWithIsset($name) |
61 | 61 | { |
62 | 62 | $list = []; |
63 | - $list[] = $this->getNullableValue($this->data['nullable'],$name); |
|
63 | + $list[] = $this->getNullableValue($this->data['nullable'], $name); |
|
64 | 64 | $list[] = (isset($this->data['autoIncrement'][$name])) ? 'AUTO_INCREMENT' : ''; |
65 | 65 | $list[] = (isset($this->data['primaryKey'][$name])) ? 'PRIMARY KEY' : ''; |
66 | 66 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | protected function getUniqueValueList($name) |
78 | 78 | { |
79 | 79 | //get unique |
80 | - if(isset($this->data['unique'][$name])){ |
|
81 | - $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['name'].' ('.$this->data['unique'][$name]['value'].' ASC)'; |
|
80 | + if (isset($this->data['unique'][$name])) { |
|
81 | + $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['name'].' ('.$this->data['unique'][$name]['value'].' ASC)'; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | protected function getIndexValueList($name) |
89 | 89 | { |
90 | 90 | //get index |
91 | - if(isset($this->data['index'][$name])){ |
|
92 | - $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['name'].' ('.$this->data['index'][$name]['value'].')'; |
|
91 | + if (isset($this->data['index'][$name])) { |
|
92 | + $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['name'].' ('.$this->data['index'][$name]['value'].')'; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | */ |
111 | 111 | protected function getCreateDefaultList() |
112 | 112 | { |
113 | - $list = []; |
|
113 | + $list = []; |
|
114 | 114 | |
115 | 115 | foreach ($this->data['names'] as $key=>$name) |
116 | 116 | { |
117 | 117 | list( |
118 | - $nullableValue,$autoIncrementValue, |
|
119 | - $primaryKeyValue,$defaultValue,$commentValue |
|
118 | + $nullableValue, $autoIncrementValue, |
|
119 | + $primaryKeyValue, $defaultValue, $commentValue |
|
120 | 120 | ) = $this->getValueWithIsset($name); |
121 | 121 | |
122 | 122 | //set index values |
123 | 123 | $this->setIndex($name); |
124 | 124 | |
125 | - $list[]=''.$name.' '.$this->data['types'][$key].' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
125 | + $list[] = ''.$name.' '.$this->data['types'][$key].' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return $list; |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function getKeyList() |
135 | 135 | { |
136 | - $keyList = []; |
|
136 | + $keyList = []; |
|
137 | 137 | |
138 | 138 | //multiple indexes |
139 | - if(isset($this->data['index']['indexes'])){ |
|
139 | + if (isset($this->data['index']['indexes'])) { |
|
140 | 140 | |
141 | - foreach ($this->data['index']['indexes'] as $index_key=>$index_value){ |
|
141 | + foreach ($this->data['index']['indexes'] as $index_key=>$index_value) { |
|
142 | 142 | |
143 | 143 | $indexesCommentValue = (isset($index_value['comment'])) ? 'COMMENT "'.$index_value['comment'].'"' : ''; |
144 | 144 | |
145 | 145 | $keyType = (isset($index_value['type'])) ? ucfirst($index_value['type']) : 'KEY'; |
146 | 146 | |
147 | - $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",",$index_value['value']).") ".$indexesCommentValue; |
|
147 | + $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",", $index_value['value']).") ".$indexesCommentValue; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | { |
160 | 160 | $list = []; |
161 | 161 | |
162 | - foreach ($reference as $constraint=>$values){ |
|
162 | + foreach ($reference as $constraint=>$values) { |
|
163 | 163 | |
164 | - $list[]=',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
164 | + $list[] = ',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
165 | 165 | REFERENCES '.$values['references']['table'].'('.$values['references']['field'].') '.$this->getOnProcess($values); |
166 | 166 | } |
167 | 167 | |
168 | - return implode (" ",$list); |
|
168 | + return implode(" ", $list); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | private function getOnProcess($referenceValue) |
175 | 175 | { |
176 | - if(isset($referenceValue['on']) && isset($referenceValue['onOption'])){ |
|
176 | + if (isset($referenceValue['on']) && isset($referenceValue['onOption'])) { |
|
177 | 177 | return ''.$referenceValue['on'].' '.strtoupper($referenceValue['onOption']).''; |
178 | 178 | } |
179 | 179 |
@@ -17,8 +17,7 @@ |
||
17 | 17 | if(isset($nullable[$name])){ |
18 | 18 | if($nullable[$name]===false){ |
19 | 19 | $nullableValue='NOT NULL'; |
20 | - } |
|
21 | - else{ |
|
20 | + } else{ |
|
22 | 21 | $nullableValue='NULL'; |
23 | 22 | } |
24 | 23 | } |
@@ -93,7 +93,7 @@ |
||
93 | 93 | //get path and set mkdir |
94 | 94 | $path = $mainPath.'/'.ucfirst($table); |
95 | 95 | if(!file_exists($path)){ |
96 | - $mkdirResults[] = mkdir($path, 0777); |
|
96 | + $mkdirResults[] = mkdir($path, 0777); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | |
36 | 36 | $paths = self::$paths; |
37 | 37 | |
38 | - foreach ($paths as $path){ |
|
38 | + foreach ($paths as $path) { |
|
39 | 39 | $globPaths = array_filter(glob($path.'/*'), 'is_dir'); |
40 | - foreach ($globPaths as $reelPath){ |
|
41 | - $list[]=$reelPath; |
|
40 | + foreach ($globPaths as $reelPath) { |
|
41 | + $list[] = $reelPath; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | |
55 | 55 | $list = []; |
56 | 56 | |
57 | - foreach ($directories as $directory){ |
|
57 | + foreach ($directories as $directory) { |
|
58 | 58 | |
59 | 59 | foreach (glob($directory."/*.php") as $file) { |
60 | 60 | |
61 | - $list[self::getFileName($directory)][]=$file; |
|
61 | + $list[self::getFileName($directory)][] = $file; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public static function getFileName($path) |
73 | 73 | { |
74 | - $pathParse = explode ("/",$path); |
|
74 | + $pathParse = explode("/", $path); |
|
75 | 75 | |
76 | 76 | return end($pathParse); |
77 | 77 | } |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | |
88 | 88 | $mkdirResults = []; |
89 | 89 | |
90 | - foreach ($tables as $table){ |
|
91 | - if(!isset($directories[$table])){ |
|
90 | + foreach ($tables as $table) { |
|
91 | + if (!isset($directories[$table])) { |
|
92 | 92 | |
93 | 93 | //get path and set mkdir |
94 | 94 | $path = $mainPath.'/'.ucfirst($table); |
95 | - if(!file_exists($path)){ |
|
95 | + if (!file_exists($path)) { |
|
96 | 96 | $mkdirResults[] = mkdir($path, 0777); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - dd(self::getAllDirectories(),$tables,$mkdirResults); |
|
101 | + dd(self::getAllDirectories(), $tables, $mkdirResults); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 |
@@ -92,8 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | if(!file_exists($tableDirectory)){ |
94 | 94 | $results['directory'][$pathKey]= $this->fileProcess($tableDirectory,'makeDirectory'); |
95 | - } |
|
96 | - else{ |
|
95 | + } else{ |
|
97 | 96 | $results['directory'][$pathKey]= $this->getResult(false, |
98 | 97 | 'Already exist the specified directory'); |
99 | 98 | } |
@@ -110,8 +109,7 @@ discard block |
||
110 | 109 | |
111 | 110 | if(!file_exists($filePath)){ |
112 | 111 | $results['file'][$pathKey]=$this->fileProcess($filePath,'makeFile'); |
113 | - } |
|
114 | - else{ |
|
112 | + } else{ |
|
115 | 113 | $results['file'][$pathKey]= $this->getResult(false, |
116 | 114 | 'Already exist the specified file'); |
117 | 115 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | private function getPaths($params) |
48 | 48 | { |
49 | - if(!isset($params[3])){ |
|
49 | + if (!isset($params[3])) { |
|
50 | 50 | return [$this->config['paths'][0]]; |
51 | 51 | } |
52 | 52 | |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | * @param $params |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | - private function fopenprocess($executionPath,$path,$params) |
|
62 | + private function fopenprocess($executionPath, $path, $params) |
|
63 | 63 | { |
64 | 64 | $dt = fopen($executionPath, "r"); |
65 | 65 | $content = fread($dt, filesize($executionPath)); |
66 | 66 | fclose($dt); |
67 | 67 | |
68 | - foreach ($params as $key=>$value){ |
|
68 | + foreach ($params as $key=>$value) { |
|
69 | 69 | |
70 | - $content=str_replace("__".$key."__",$value,$content); |
|
70 | + $content = str_replace("__".$key."__", $value, $content); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -86,28 +86,28 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function get($params) |
88 | 88 | { |
89 | - list($table,$name,$type) = $params; |
|
89 | + list($table, $name, $type) = $params; |
|
90 | 90 | |
91 | 91 | $results = []; |
92 | 92 | |
93 | 93 | $paths = $this->getPaths($params); |
94 | 94 | |
95 | - foreach ($paths as $pathKey=>$path){ |
|
95 | + foreach ($paths as $pathKey=>$path) { |
|
96 | 96 | |
97 | 97 | $tableDirectory = $path.'/'.ucfirst($table); |
98 | 98 | |
99 | 99 | |
100 | - if(!file_exists($tableDirectory)){ |
|
101 | - $results['directory'][$pathKey]= $this->fileProcess($tableDirectory,'makeDirectory'); |
|
100 | + if (!file_exists($tableDirectory)) { |
|
101 | + $results['directory'][$pathKey] = $this->fileProcess($tableDirectory, 'makeDirectory'); |
|
102 | 102 | } |
103 | - else{ |
|
104 | - $results['directory'][$pathKey]= $this->getResult(false, |
|
103 | + else { |
|
104 | + $results['directory'][$pathKey] = $this->getResult(false, |
|
105 | 105 | 'Already exist the specified directory'); |
106 | 106 | } |
107 | 107 | |
108 | - $results['directory'][$pathKey]['table']= $table; |
|
109 | - $results['directory'][$pathKey]['directory']= $table; |
|
110 | - $results['directory'][$pathKey]['type']= $type; |
|
108 | + $results['directory'][$pathKey]['table'] = $table; |
|
109 | + $results['directory'][$pathKey]['directory'] = $table; |
|
110 | + $results['directory'][$pathKey]['type'] = $type; |
|
111 | 111 | |
112 | 112 | $fileName = ucfirst($name); |
113 | 113 | |
@@ -115,23 +115,23 @@ discard block |
||
115 | 115 | |
116 | 116 | $filePath = $tableDirectory.'/'.$fileNameWithTime.'.php'; |
117 | 117 | |
118 | - if(!file_exists($filePath)){ |
|
119 | - $results['file'][$pathKey]=$this->fileProcess($filePath,'makeFile'); |
|
118 | + if (!file_exists($filePath)) { |
|
119 | + $results['file'][$pathKey] = $this->fileProcess($filePath, 'makeFile'); |
|
120 | 120 | } |
121 | - else{ |
|
122 | - $results['file'][$pathKey]= $this->getResult(false, |
|
121 | + else { |
|
122 | + $results['file'][$pathKey] = $this->getResult(false, |
|
123 | 123 | 'Already exist the specified file'); |
124 | 124 | } |
125 | 125 | |
126 | - $results['file'][$pathKey]['table']=$table; |
|
127 | - $results['file'][$pathKey]['file']=$fileName; |
|
128 | - $results['file'][$pathKey]['type']=$type; |
|
126 | + $results['file'][$pathKey]['table'] = $table; |
|
127 | + $results['file'][$pathKey]['file'] = $fileName; |
|
128 | + $results['file'][$pathKey]['type'] = $type; |
|
129 | 129 | |
130 | 130 | $stubber = $this->stubber.'/'.$type.'.stub'; |
131 | 131 | |
132 | - $this->fopenprocess($stubber,$filePath,['className'=>$fileName]); |
|
132 | + $this->fopenprocess($stubber, $filePath, ['className'=>$fileName]); |
|
133 | 133 | |
134 | - $this->file->chmod($tableDirectory,0777,000,true); |
|
134 | + $this->file->chmod($tableDirectory, 0777, 000, true); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return $results; |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param $process |
143 | 143 | * @return array |
144 | 144 | */ |
145 | - private function fileProcess($path,$process) |
|
145 | + private function fileProcess($path, $process) |
|
146 | 146 | { |
147 | 147 | try { |
148 | 148 | $this->{$process}($path); |
149 | - return $this->getResult(true,null); |
|
149 | + return $this->getResult(true, null); |
|
150 | 150 | } catch (IOExceptionInterface $exception) { |
151 | 151 | return $this->getResult(false, |
152 | 152 | "An error occurred while creating your directory at ".$exception->getPath().""); |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param $path |
158 | 158 | * @param int $mode |
159 | 159 | */ |
160 | - private function makeDirectory($path,$mode=0777) |
|
160 | + private function makeDirectory($path, $mode = 0777) |
|
161 | 161 | { |
162 | - return $this->file->mkdir($path,$mode); |
|
162 | + return $this->file->mkdir($path, $mode); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param $message |
176 | 176 | * @return array |
177 | 177 | */ |
178 | - private function getResult($success,$message) |
|
178 | + private function getResult($success, $message) |
|
179 | 179 | { |
180 | 180 | return [ |
181 | 181 | 'success'=>$success, |
@@ -13,6 +13,6 @@ |
||
13 | 13 | * @param array $tables |
14 | 14 | * @return mixed |
15 | 15 | */ |
16 | - public function getColumns($tables=array()); |
|
16 | + public function getColumns($tables = array()); |
|
17 | 17 | |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param bool $table |
17 | 17 | * @return TablePropertiesContract |
18 | 18 | */ |
19 | - public function collation($value,$table=false); |
|
19 | + public function collation($value, $table = false); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param $value |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param bool $key |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - public function index($name=null,$value=null,$key=false); |
|
39 | + public function index($name = null, $value = null, $key = false); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param $value |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param bool $null |
49 | 49 | * @return $this |
50 | 50 | */ |
51 | - public function nullable($null=true); |
|
51 | + public function nullable($null = true); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @return $this |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param null $value |
66 | 66 | * @return mixed |
67 | 67 | */ |
68 | - public function unique($name=null,$value=null); |
|
68 | + public function unique($name = null, $value = null); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 |
@@ -9,6 +9,6 @@ |
||
9 | 9 | * @param string $field |
10 | 10 | * @return OptionsContract |
11 | 11 | */ |
12 | - public function references($table,$field='id'); |
|
12 | + public function references($table, $field = 'id'); |
|
13 | 13 | } |
14 | 14 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | * @param array $tables |
14 | 14 | * @return mixed |
15 | 15 | */ |
16 | - public function fields($tables=array()); |
|
16 | + public function fields($tables = array()); |
|
17 | 17 | |
18 | 18 | } |
19 | 19 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param array $tables |
19 | 19 | * @return SchemaContract |
20 | 20 | */ |
21 | - public function tables($tables=array()); |
|
21 | + public function tables($tables = array()); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param $table |
@@ -27,5 +27,5 @@ discard block |
||
27 | 27 | * @param array $paths |
28 | 28 | * @return mixed |
29 | 29 | */ |
30 | - public function stub($table,$type,$name,$paths=[0]); |
|
30 | + public function stub($table, $type, $name, $paths = [0]); |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |