@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Migratio\Contract\WizardContract; |
6 | 6 | use Migratio\Contract\WizardAlterContract; |
7 | 7 | |
8 | -class WizardAlter extends Wizard implements WizardContract,WizardAlterContract |
|
8 | +class WizardAlter extends Wizard implements WizardContract, WizardAlterContract |
|
9 | 9 | { |
10 | 10 | /** |
11 | 11 | * @var string |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function after($field) |
29 | 29 | { |
30 | - $this->wizard->setAlterType('place',['AFTER'=>$field]); |
|
30 | + $this->wizard->setAlterType('place', ['AFTER'=>$field]); |
|
31 | 31 | |
32 | 32 | return $this->wizard; |
33 | 33 | } |
@@ -17,8 +17,7 @@ discard block |
||
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 | } |
@@ -72,8 +71,7 @@ discard block |
||
72 | 71 | |
73 | 72 | if($this->data['types'][$nameKey]!=='timestamp'){ |
74 | 73 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
75 | - } |
|
76 | - else{ |
|
74 | + } else{ |
|
77 | 75 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
78 | 76 | } |
79 | 77 |
@@ -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 | |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected function getValueWithIsset($name) |
61 | 61 | { |
62 | - $nameKey = array_search($name,$this->data['names']); |
|
62 | + $nameKey = array_search($name, $this->data['names']); |
|
63 | 63 | |
64 | 64 | $list = []; |
65 | - $list[] = $this->getNullableValue($this->data['nullable'],$name); |
|
65 | + $list[] = $this->getNullableValue($this->data['nullable'], $name); |
|
66 | 66 | $list[] = (isset($this->data['autoIncrement'][$name])) ? 'AUTO_INCREMENT' : ''; |
67 | 67 | $list[] = (isset($this->data['primaryKey'][$name])) ? 'PRIMARY KEY' : ''; |
68 | 68 | |
69 | - if($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])){ |
|
69 | + if ($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])) { |
|
70 | 70 | $this->data['default'][$name] = 'CURRENT_TIMESTAMP'; |
71 | 71 | } |
72 | 72 | |
73 | - if($this->data['types'][$nameKey]!=='timestamp'){ |
|
73 | + if ($this->data['types'][$nameKey]!=='timestamp') { |
|
74 | 74 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
75 | 75 | } |
76 | - else{ |
|
76 | + else { |
|
77 | 77 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
78 | 78 | } |
79 | 79 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | protected function getUniqueValueList($name) |
91 | 91 | { |
92 | 92 | //get unique |
93 | - if(isset($this->data['unique'][$name])){ |
|
94 | - $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
93 | + if (isset($this->data['unique'][$name])) { |
|
94 | + $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | protected function getIndexValueList($name) |
102 | 102 | { |
103 | 103 | //get index |
104 | - if(isset($this->data['index'][$name])){ |
|
105 | - $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
104 | + if (isset($this->data['index'][$name])) { |
|
105 | + $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -123,19 +123,19 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function getCreateDefaultList() |
125 | 125 | { |
126 | - $list = []; |
|
126 | + $list = []; |
|
127 | 127 | |
128 | 128 | foreach ($this->data['names'] as $key=>$name) |
129 | 129 | { |
130 | 130 | list( |
131 | - $nullableValue,$autoIncrementValue, |
|
132 | - $primaryKeyValue,$defaultValue,$commentValue |
|
131 | + $nullableValue, $autoIncrementValue, |
|
132 | + $primaryKeyValue, $defaultValue, $commentValue |
|
133 | 133 | ) = $this->getValueWithIsset($name); |
134 | 134 | |
135 | 135 | //set index values |
136 | 136 | $this->setIndex($name); |
137 | 137 | |
138 | - $list[]=''.$name.' '.$this->data['types'][$key].' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
138 | + $list[] = ''.$name.' '.$this->data['types'][$key].' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $list; |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function getKeyList() |
148 | 148 | { |
149 | - $keyList = []; |
|
149 | + $keyList = []; |
|
150 | 150 | |
151 | 151 | //multiple indexes |
152 | - if(isset($this->data['index']['indexes'])){ |
|
152 | + if (isset($this->data['index']['indexes'])) { |
|
153 | 153 | |
154 | - foreach ($this->data['index']['indexes'] as $index_key=>$index_value){ |
|
154 | + foreach ($this->data['index']['indexes'] as $index_key=>$index_value) { |
|
155 | 155 | |
156 | 156 | $indexesCommentValue = (isset($index_value['comment'])) ? 'COMMENT "'.$index_value['comment'].'"' : ''; |
157 | 157 | |
158 | 158 | $keyType = (isset($index_value['type'])) ? ucfirst($index_value['type']) : 'KEY'; |
159 | 159 | |
160 | - $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",",$index_value['value']).") ".$indexesCommentValue; |
|
160 | + $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",", $index_value['value']).") ".$indexesCommentValue; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | { |
173 | 173 | $list = []; |
174 | 174 | |
175 | - foreach ($reference as $constraint=>$values){ |
|
175 | + foreach ($reference as $constraint=>$values) { |
|
176 | 176 | |
177 | - $list[]=',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
177 | + $list[] = ',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
178 | 178 | REFERENCES '.$values['references']['table'].'('.$values['references']['field'].') '.$this->getOnProcess($values); |
179 | 179 | } |
180 | 180 | |
181 | - return implode (" ",$list); |
|
181 | + return implode(" ", $list); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | private function getOnProcess($referenceValue) |
188 | 188 | { |
189 | - if(isset($referenceValue['on']) && isset($referenceValue['onOption'])){ |
|
189 | + if (isset($referenceValue['on']) && isset($referenceValue['onOption'])) { |
|
190 | 190 | return ''.$referenceValue['on'].' '.strtoupper($referenceValue['onOption']).''; |
191 | 191 | } |
192 | 192 |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | |
26 | 26 | $this->getDefaultSyntaxGroup(); |
27 | 27 | |
28 | - $this->syntax[]=')'; |
|
28 | + $this->syntax[] = ')'; |
|
29 | 29 | |
30 | 30 | //get table collation |
31 | - if(isset($this->data['tableCollation']['table'])){ |
|
32 | - $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
31 | + if (isset($this->data['tableCollation']['table'])) { |
|
32 | + $this->syntax[] = ' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
33 | 33 | } |
34 | - else{ |
|
35 | - $this->syntax[]=' DEFAULT CHARACTER SET utf8'; |
|
34 | + else { |
|
35 | + $this->syntax[] = ' DEFAULT CHARACTER SET utf8'; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | //get engine |
39 | - if($this->data['engine']!==null) |
|
39 | + if ($this->data['engine']!==null) |
|
40 | 40 | { |
41 | - $this->syntax[]=' ENGINE='.$this->data['engine'].' '; |
|
41 | + $this->syntax[] = ' ENGINE='.$this->data['engine'].' '; |
|
42 | 42 | } |
43 | - else{ |
|
44 | - $this->syntax[]=' ENGINE=InnoDB '; |
|
43 | + else { |
|
44 | + $this->syntax[] = ' ENGINE=InnoDB '; |
|
45 | 45 | } |
46 | 46 | |
47 | - $syntax = implode("",$this->syntax); |
|
47 | + $syntax = implode("", $this->syntax); |
|
48 | 48 | |
49 | - $query=$this->schema->getConnection()->setQueryBasic($syntax); |
|
49 | + $query = $this->schema->getConnection()->setQueryBasic($syntax); |
|
50 | 50 | |
51 | 51 | return [ |
52 | 52 | 'syntax'=>$syntax, |
@@ -62,25 +62,25 @@ discard block |
||
62 | 62 | private function getDefaultSyntaxGroup() |
63 | 63 | { |
64 | 64 | |
65 | - $this->syntax[]=implode(",",$this->getCreateDefaultList()); |
|
65 | + $this->syntax[] = implode(",", $this->getCreateDefaultList()); |
|
66 | 66 | |
67 | 67 | //get unique values |
68 | - if(isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])){ |
|
69 | - $this->syntax[]=','.implode(',',$this->data['uniqueValueList']); |
|
68 | + if (isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])) { |
|
69 | + $this->syntax[] = ','.implode(',', $this->data['uniqueValueList']); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | //get index values |
73 | - if(isset($this->data['indexValueList']) && count($this->data['indexValueList'])){ |
|
74 | - $this->syntax[]=','.implode(',',$this->data['indexValueList']); |
|
73 | + if (isset($this->data['indexValueList']) && count($this->data['indexValueList'])) { |
|
74 | + $this->syntax[] = ','.implode(',', $this->data['indexValueList']); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | //get index values for key |
78 | - if(count($this->getKeyList())){ |
|
79 | - $this->syntax[]=','.implode(',',$this->getKeyList()); |
|
78 | + if (count($this->getKeyList())) { |
|
79 | + $this->syntax[] = ','.implode(',', $this->getKeyList()); |
|
80 | 80 | } |
81 | 81 | |
82 | - if(count($this->data['references'])){ |
|
83 | - $this->syntax[]=$this->getReferenceSyntax($this->data['references']); |
|
82 | + if (count($this->data['references'])) { |
|
83 | + $this->syntax[] = $this->getReferenceSyntax($this->data['references']); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -104,33 +104,33 @@ discard block |
||
104 | 104 | |
105 | 105 | private function change($alterType) |
106 | 106 | { |
107 | - if(isset($alterType['place'])){ |
|
107 | + if (isset($alterType['place'])) { |
|
108 | 108 | |
109 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
110 | - $placeList=$placeKey .' '.$placeValue.''; |
|
109 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
110 | + $placeList = $placeKey.' '.$placeValue.''; |
|
111 | 111 | } |
112 | 112 | |
113 | - $syntax = implode("",$this->syntax); |
|
113 | + $syntax = implode("", $this->syntax); |
|
114 | 114 | |
115 | 115 | $columns = $this->schema->getConnection()->showColumnsFrom($this->table); |
116 | 116 | |
117 | - foreach ($columns as $columnKey=>$columnData){ |
|
118 | - if($columnData['Field']==$placeValue){ |
|
117 | + foreach ($columns as $columnKey=>$columnData) { |
|
118 | + if ($columnData['Field']==$placeValue) { |
|
119 | 119 | $changeAbleField = $columns[$columnKey+1]['Field']; |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - $syntaxList = explode(' ',$syntax); |
|
123 | + $syntaxList = explode(' ', $syntax); |
|
124 | 124 | |
125 | - if(current($syntaxList)!==$changeAbleField){ |
|
126 | - $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ',array_splice($syntaxList,1)).' '.$placeList; |
|
125 | + if (current($syntaxList)!==$changeAbleField) { |
|
126 | + $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ', array_splice($syntaxList, 1)).' '.$placeList; |
|
127 | 127 | } |
128 | - else{ |
|
128 | + else { |
|
129 | 129 | $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList; |
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
133 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
134 | 134 | |
135 | 135 | return [ |
136 | 136 | 'syntax'=>$syntax, |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | |
144 | 144 | private function addColumn($alterType) |
145 | 145 | { |
146 | - if(isset($alterType['place'])){ |
|
146 | + if (isset($alterType['place'])) { |
|
147 | 147 | |
148 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
149 | - $placeList=$placeKey .' '.$placeValue.''; |
|
148 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
149 | + $placeList = $placeKey.' '.$placeValue.''; |
|
150 | 150 | } |
151 | 151 | |
152 | - $syntax = implode("",$this->syntax); |
|
152 | + $syntax = implode("", $this->syntax); |
|
153 | 153 | |
154 | 154 | $alterSytanx = 'ALTER TABLE '.$this->table.' ADD COLUMN '.$syntax.' '.$placeList; |
155 | 155 | |
156 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
156 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
157 | 157 | |
158 | 158 | return [ |
159 | 159 | 'syntax'=>$syntax, |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | //get table collation |
31 | 31 | if(isset($this->data['tableCollation']['table'])){ |
32 | 32 | $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
33 | - } |
|
34 | - else{ |
|
33 | + } else{ |
|
35 | 34 | $this->syntax[]=' DEFAULT CHARACTER SET utf8'; |
36 | 35 | } |
37 | 36 | |
@@ -39,8 +38,7 @@ discard block |
||
39 | 38 | if($this->data['engine']!==null) |
40 | 39 | { |
41 | 40 | $this->syntax[]=' ENGINE='.$this->data['engine'].' '; |
42 | - } |
|
43 | - else{ |
|
41 | + } else{ |
|
44 | 42 | $this->syntax[]=' ENGINE=InnoDB '; |
45 | 43 | } |
46 | 44 | |
@@ -124,8 +122,7 @@ discard block |
||
124 | 122 | |
125 | 123 | if(current($syntaxList)!==$changeAbleField){ |
126 | 124 | $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ',array_splice($syntaxList,1)).' '.$placeList; |
127 | - } |
|
128 | - else{ |
|
125 | + } else{ |
|
129 | 126 | $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList; |
130 | 127 | } |
131 | 128 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var $type |
16 | 16 | */ |
17 | - public $type='project'; |
|
17 | + public $type = 'project'; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @var array |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @var $commandRule |
33 | 33 | */ |
34 | - public $commandRule=[]; |
|
34 | + public $commandRule = []; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @method create |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | $this->directory['projectDir'] = $this->projectPath(); |
47 | 47 | $this->argument['exceptionNamespace'] = app()->namespace()->exception(); |
48 | 48 | $this->argument['resourcePath'] = app()->path()->appResourche(); |
49 | - $this->argument['testNamespace'] = app()->namespace()->tests(); |
|
49 | + $this->argument['testNamespace'] = app()->namespace()->tests(); |
|
50 | 50 | |
51 | - $recursiveDefaultDirectory = explode("\\",$this->argument['project']); |
|
51 | + $recursiveDefaultDirectory = explode("\\", $this->argument['project']); |
|
52 | 52 | $this->argument['applicationName'] = pos($recursiveDefaultDirectory); |
53 | 53 | $recursiveDefaultDirectory[] = 'V1'; |
54 | 54 | $recursiveDefaultDirectoryList = []; |
55 | 55 | |
56 | - foreach (array_slice($recursiveDefaultDirectory,1) as $defaultDirectory){ |
|
56 | + foreach (array_slice($recursiveDefaultDirectory, 1) as $defaultDirectory) { |
|
57 | 57 | |
58 | - $recursiveDefaultDirectoryList[]=$defaultDirectory; |
|
59 | - $this->directory[$defaultDirectory.'Path'] = $this->projectPath().''.implode("/",$recursiveDefaultDirectoryList); |
|
58 | + $recursiveDefaultDirectoryList[] = $defaultDirectory; |
|
59 | + $this->directory[$defaultDirectory.'Path'] = $this->projectPath().''.implode("/", $recursiveDefaultDirectoryList); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | //$this->directory['optionalDir'] = $this->optional(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | //$this->directory['sourceDir'] = $this->sourceDir(); |
83 | 83 | //$this->directory['sourceSupportDir'] = $this->sourceSupportDir(); |
84 | 84 | //$this->directory['sourceSupportTraitDir'] = $this->sourceSupportDir().'/Traits'; |
85 | - $this->directory['exceptionDir'] = app()->path()->exception(); |
|
85 | + $this->directory['exceptionDir'] = app()->path()->exception(); |
|
86 | 86 | |
87 | 87 | //set project directory |
88 | 88 | $this->file->makeDirectory($this); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $this->touch['kernel/worker'] = $this->provider().'/WorkerServiceProvider.php'; |
98 | 98 | $this->touch['kernel/authenticate'] = $this->provider().'/AuthenticateServiceProvider.php'; |
99 | 99 | $this->touch['kernel/role'] = $this->provider().'/RoleServiceProvider.php'; |
100 | - $this->touch['test/testcase'] = $this->test().'/TestCase.php'; |
|
100 | + $this->touch['test/testcase'] = $this->test().'/TestCase.php'; |
|
101 | 101 | $this->touch['kernel/consoleevent'] = $this->provider().'/ConsoleEventServiceProvider.php'; |
102 | 102 | $this->touch['middleware/authenticate'] = $this->middleware().'/Authenticate.php'; |
103 | 103 | $this->touch['middleware/ratelimit'] = $this->middleware().'/RateLimit.php'; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $this->touch['app/gitignore'] = $this->projectPath().'/.gitignore'; |
137 | 137 | $this->touch['app/composer'] = $this->projectPath().'/composer.json'; |
138 | 138 | $this->touch['test/index'] = $this->storage().'/index.html'; |
139 | - $this->touch['exception/authenticate'] = $this->directory['exceptionDir'] .'/AuthenticateException.php'; |
|
139 | + $this->touch['exception/authenticate'] = $this->directory['exceptionDir'].'/AuthenticateException.php'; |
|
140 | 140 | |
141 | 141 | //set project touch |
142 | 142 | $this->file->touch($this); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @var null |
9 | 9 | */ |
10 | - public $credentialHash=null; |
|
10 | + public $credentialHash = null; |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @return string |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | // the absolute params property must be present |
18 | 18 | // in the object and the params value must be the builder key. |
19 | - if(property_exists($this,'params') and isset($this->params['builder'])){ |
|
19 | + if (property_exists($this, 'params') and isset($this->params['builder'])) { |
|
20 | 20 | |
21 | 21 | // a real token will be generated after |
22 | 22 | // you get the first method of the query builder value. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | // we refer to the token closure feature on the config to enable |
26 | 26 | // the creation of user-based tokens on the application side. |
27 | - return $this->getTokenFromProvider($authData,function() use($authData){ |
|
27 | + return $this->getTokenFromProvider($authData, function() use($authData){ |
|
28 | 28 | return md5(sha1($authData->id.'__'.$this->credentialHash.'__'.time().'__'.fingerPrint())); |
29 | 29 | }); |
30 | 30 | } |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | * @param callable $callback |
38 | 38 | * @return mixed |
39 | 39 | */ |
40 | - private function getTokenFromProvider($authData,callable $callback) |
|
40 | + private function getTokenFromProvider($authData, callable $callback) |
|
41 | 41 | { |
42 | 42 | // if the token value is a closure value, |
43 | 43 | // we will run a user-based token closure. |
44 | - if(app()->has('authenticate.token') && is_callable($token = app()->get('authenticate.token'))){ |
|
44 | + if (app()->has('authenticate.token') && is_callable($token = app()->get('authenticate.token'))) { |
|
45 | 45 | return $token($authData); |
46 | 46 | } |
47 | 47 |
@@ -19,19 +19,19 @@ discard block |
||
19 | 19 | * @param $command |
20 | 20 | * @param $args |
21 | 21 | */ |
22 | - public function __construct($app,$command,$args) |
|
22 | + public function __construct($app, $command, $args) |
|
23 | 23 | { |
24 | 24 | parent::__construct($app); |
25 | 25 | |
26 | 26 | $this->arguments[] = 'php'; |
27 | 27 | $this->arguments[] = 'api'; |
28 | - $this->arguments = array_merge($this->arguments,explode(" ",$command)); |
|
28 | + $this->arguments = array_merge($this->arguments, explode(" ", $command)); |
|
29 | 29 | $this->arguments[] = strtolower(app); |
30 | 30 | |
31 | - $argsList = explode(' ',$args); |
|
31 | + $argsList = explode(' ', $args); |
|
32 | 32 | |
33 | 33 | foreach ($argsList as $item) { |
34 | - $this->arguments[] = $item; |
|
34 | + $this->arguments[] = $item; |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function handle() |
44 | 44 | { |
45 | - $process = new ProcessHandler($this->arguments,root.''); |
|
45 | + $process = new ProcessHandler($this->arguments, root.''); |
|
46 | 46 | $process->start(); |
47 | 47 | |
48 | 48 | foreach ($process as $type => $data) { |
49 | - if ($process::OUT !== $type) { |
|
49 | + if ($process::OUT!==$type) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | return true; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | $list = []; |
23 | 23 | |
24 | - foreach ($migrations as $table=>$item){ |
|
24 | + foreach ($migrations as $table=>$item) { |
|
25 | 25 | $list[] = strtolower($table); |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | echo 'Toplam : '.count($dbtables).' Table'; |
31 | 31 | echo PHP_EOL; |
32 | 32 | |
33 | - foreach ($dbtables as $dbtablekey=>$dbtable){ |
|
33 | + foreach ($dbtables as $dbtablekey=>$dbtable) { |
|
34 | 34 | |
35 | 35 | $dbtablekey = $dbtablekey+1; |
36 | 36 | |
@@ -39,40 +39,40 @@ discard block |
||
39 | 39 | $dbtable = ucfirst($dbtable); |
40 | 40 | $makeDirectory = $directory.''.DIRECTORY_SEPARATOR.''.$dbtable; |
41 | 41 | |
42 | - if(!file_exists($makeDirectory)){ |
|
43 | - files()->makeDirectory($makeDirectory,0755,true); |
|
44 | - $exist=false; |
|
42 | + if (!file_exists($makeDirectory)) { |
|
43 | + files()->makeDirectory($makeDirectory, 0755, true); |
|
44 | + $exist = false; |
|
45 | 45 | } |
46 | - else{ |
|
47 | - $exist=true; |
|
46 | + else { |
|
47 | + $exist = true; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $migrationName = time().'_'.$dbtable.''; |
51 | 51 | |
52 | - if($exist===false){ |
|
52 | + if ($exist===false) { |
|
53 | 53 | |
54 | - $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub',[ |
|
54 | + $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub', [ |
|
55 | 55 | 'className' => $dbtable, |
56 | 56 | 'informations' => $informations |
57 | 57 | ]); |
58 | 58 | |
59 | - $contentResult = files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php',$content); |
|
59 | + $contentResult = files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php', $content); |
|
60 | 60 | } |
61 | 61 | |
62 | - if(substr($dbtable,-1)=='s'){ |
|
63 | - app()->command('model create','model:'.strtolower(substr($dbtable,0,-1)).' table:'.$dbtable); |
|
62 | + if (substr($dbtable, -1)=='s') { |
|
63 | + app()->command('model create', 'model:'.strtolower(substr($dbtable, 0, -1)).' table:'.$dbtable); |
|
64 | 64 | } |
65 | - else{ |
|
66 | - app()->command('model create','model:'.strtolower($dbtable).' table:'.$dbtable); |
|
65 | + else { |
|
66 | + app()->command('model create', 'model:'.strtolower($dbtable).' table:'.$dbtable); |
|
67 | 67 | } |
68 | 68 | |
69 | - if(isset($contentResult) && $contentResult!==false){ |
|
69 | + if (isset($contentResult) && $contentResult!==false) { |
|
70 | 70 | echo $dbtablekey.'- '.$migrationName.' ---> Ok'; |
71 | 71 | } |
72 | - elseif($exist){ |
|
72 | + elseif ($exist) { |
|
73 | 73 | echo $dbtablekey.'- '.$migrationName.' ---> (Already Exist)'; |
74 | 74 | } |
75 | - else{ |
|
75 | + else { |
|
76 | 76 | echo $dbtablekey.'- '.$migrationName.' ---> Fail'; |
77 | 77 | } |
78 | 78 | |
@@ -100,46 +100,46 @@ discard block |
||
100 | 100 | |
101 | 101 | $list = []; |
102 | 102 | |
103 | - foreach ($columns as $key=>$data){ |
|
103 | + foreach ($columns as $key=>$data) { |
|
104 | 104 | |
105 | - $data['Type'] = rtrim(str_replace('unsigned','',$data['Type'])); |
|
105 | + $data['Type'] = rtrim(str_replace('unsigned', '', $data['Type'])); |
|
106 | 106 | |
107 | 107 | $field = $data['Field']; |
108 | 108 | $list[] = '$wizard->name(\''.$field.'\')'; |
109 | 109 | $list[] = '->'.$this->getColumnTransformers($data['Type']).''; |
110 | 110 | |
111 | 111 | //default block |
112 | - if(!is_null($data['Default'])){ |
|
112 | + if (!is_null($data['Default'])) { |
|
113 | 113 | $default = $data['Default']; |
114 | - $list[] = '->default(\''.$default.'\')'; |
|
114 | + $list[] = '->default(\''.$default.'\')'; |
|
115 | 115 | } |
116 | 116 | |
117 | - $getIndex = $this->getIndexInformation($indexes,$data['Field']); |
|
117 | + $getIndex = $this->getIndexInformation($indexes, $data['Field']); |
|
118 | 118 | |
119 | 119 | //unique block |
120 | - if($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY'){ |
|
120 | + if ($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY') { |
|
121 | 121 | $indexName = $getIndex['Key_name']; |
122 | - $list[] = '->unique(\''.$indexName.'\')'; |
|
122 | + $list[] = '->unique(\''.$indexName.'\')'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | //index block |
126 | - if($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY'){ |
|
126 | + if ($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY') { |
|
127 | 127 | $columnName = $getIndex['Column_name']; |
128 | 128 | $indexName = $getIndex['Key_name']; |
129 | 129 | |
130 | - if(count($multipleIndexes[$indexName])==1){ |
|
130 | + if (count($multipleIndexes[$indexName])==1) { |
|
131 | 131 | $list[] = '->index(\''.$indexName.'\')'; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | //comment block |
136 | - if(strlen($data['Comment'])>0){ |
|
136 | + if (strlen($data['Comment'])>0) { |
|
137 | 137 | $comment = $data['Comment']; |
138 | 138 | $list[] = '->comment(\''.$comment.'\')'; |
139 | 139 | } |
140 | 140 | |
141 | 141 | //auto increment block |
142 | - if($data['Extra']=='auto_increment'){ |
|
142 | + if ($data['Extra']=='auto_increment') { |
|
143 | 143 | $list[] = '->auto_increment()'; |
144 | 144 | } |
145 | 145 | |
@@ -154,39 +154,39 @@ discard block |
||
154 | 154 | |
155 | 155 | //table indexes |
156 | 156 | foreach ($multipleIndexes as $indexName=>$values) { |
157 | - if(count($values)>1){ |
|
158 | - $values = '\''.implode('\',\'',$values).'\''; |
|
157 | + if (count($values)>1) { |
|
158 | + $values = '\''.implode('\',\'', $values).'\''; |
|
159 | 159 | $list[] = ' $wizard->table()->indexes(\''.$indexName.'\',['.$values.']); |
160 | 160 | '; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - if(count($foreignKeys)){ |
|
164 | + if (count($foreignKeys)) { |
|
165 | 165 | |
166 | 166 | $constraintName = $foreignKeys['CONSTRAINT_NAME']; |
167 | 167 | $key = $foreignKeys['COLUMN_NAME']; |
168 | 168 | $referenceTable = $foreignKeys['REFERENCED_TABLE_NAME']; |
169 | 169 | $referenceColumn = $foreignKeys['REFERENCED_COLUMN_NAME']; |
170 | 170 | |
171 | - if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){ |
|
171 | + if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') { |
|
172 | 172 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\'); |
173 | 173 | '; |
174 | 174 | } |
175 | 175 | |
176 | - if($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){ |
|
176 | + if ($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') { |
|
177 | 177 | $rule = $foreignKeys['UPDATE_RULE']; |
178 | 178 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onUpdate()->'.strtolower($rule).'(); |
179 | 179 | '; |
180 | 180 | } |
181 | 181 | |
182 | - if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT'){ |
|
182 | + if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT') { |
|
183 | 183 | $rule = $foreignKeys['DELETE_RULE']; |
184 | 184 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onDelete()->'.strtolower($rule).'(); |
185 | 185 | '; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - return implode('',$list); |
|
189 | + return implode('', $list); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -197,43 +197,43 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function getColumnTransformers($column) |
199 | 199 | { |
200 | - if($column=='datetime'){ |
|
200 | + if ($column=='datetime') { |
|
201 | 201 | return 'datetime()'; |
202 | 202 | } |
203 | - elseif($column=='longtext'){ |
|
203 | + elseif ($column=='longtext') { |
|
204 | 204 | return 'longtext()'; |
205 | 205 | } |
206 | - elseif($column=='date'){ |
|
206 | + elseif ($column=='date') { |
|
207 | 207 | return 'date()'; |
208 | 208 | } |
209 | - elseif($column=='text'){ |
|
209 | + elseif ($column=='text') { |
|
210 | 210 | return 'text()'; |
211 | 211 | } |
212 | - elseif($column=='timestamp'){ |
|
212 | + elseif ($column=='timestamp') { |
|
213 | 213 | return 'timestamp()'; |
214 | 214 | } |
215 | - elseif($column=='mediumint'){ |
|
215 | + elseif ($column=='mediumint') { |
|
216 | 216 | return 'mediumint()'; |
217 | 217 | } |
218 | - elseif($column=='tinyint'){ |
|
218 | + elseif ($column=='tinyint') { |
|
219 | 219 | return 'tinyint()'; |
220 | 220 | } |
221 | - elseif($column=='float'){ |
|
221 | + elseif ($column=='float') { |
|
222 | 222 | return 'float()'; |
223 | 223 | } |
224 | - elseif($column=='mediumtext'){ |
|
224 | + elseif ($column=='mediumtext') { |
|
225 | 225 | return 'mediumtext()'; |
226 | 226 | } |
227 | - elseif($column=='mediumblob'){ |
|
227 | + elseif ($column=='mediumblob') { |
|
228 | 228 | return 'mediumblob()'; |
229 | 229 | } |
230 | - elseif($column=='blob'){ |
|
230 | + elseif ($column=='blob') { |
|
231 | 231 | return 'blob()'; |
232 | 232 | } |
233 | - elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
233 | + elseif (preg_match('@enum.*\((.*?)\)@', $column, $enum)) { |
|
234 | 234 | return 'enum(['.$enum[1].'])'; |
235 | 235 | } |
236 | - else{ |
|
236 | + else { |
|
237 | 237 | return $column; |
238 | 238 | } |
239 | 239 | } |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param $field |
246 | 246 | * @return void|mixed |
247 | 247 | */ |
248 | - private function getIndexInformation($index,$field) |
|
248 | + private function getIndexInformation($index, $field) |
|
249 | 249 | { |
250 | 250 | foreach ($index as $key=>$item) { |
251 | 251 | |
252 | - if($item['Column_name'] == $field){ |
|
252 | + if ($item['Column_name']==$field) { |
|
253 | 253 | return $index[$key]; |
254 | 254 | } |
255 | 255 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $list = []; |
270 | 270 | foreach ($index as $key=>$item) { |
271 | - if($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY'){ |
|
271 | + if ($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY') { |
|
272 | 272 | $list[$item['Key_name']][] = $item['Column_name']; |
273 | 273 | } |
274 | 274 | } |
@@ -42,8 +42,7 @@ discard block |
||
42 | 42 | if(!file_exists($makeDirectory)){ |
43 | 43 | files()->makeDirectory($makeDirectory,0755,true); |
44 | 44 | $exist=false; |
45 | - } |
|
46 | - else{ |
|
45 | + } else{ |
|
47 | 46 | $exist=true; |
48 | 47 | } |
49 | 48 | |
@@ -61,18 +60,15 @@ discard block |
||
61 | 60 | |
62 | 61 | if(substr($dbtable,-1)=='s'){ |
63 | 62 | app()->command('model create','model:'.strtolower(substr($dbtable,0,-1)).' table:'.$dbtable); |
64 | - } |
|
65 | - else{ |
|
63 | + } else{ |
|
66 | 64 | app()->command('model create','model:'.strtolower($dbtable).' table:'.$dbtable); |
67 | 65 | } |
68 | 66 | |
69 | 67 | if(isset($contentResult) && $contentResult!==false){ |
70 | 68 | echo $dbtablekey.'- '.$migrationName.' ---> Ok'; |
71 | - } |
|
72 | - elseif($exist){ |
|
69 | + } elseif($exist){ |
|
73 | 70 | echo $dbtablekey.'- '.$migrationName.' ---> (Already Exist)'; |
74 | - } |
|
75 | - else{ |
|
71 | + } else{ |
|
76 | 72 | echo $dbtablekey.'- '.$migrationName.' ---> Fail'; |
77 | 73 | } |
78 | 74 | |
@@ -199,41 +195,29 @@ discard block |
||
199 | 195 | { |
200 | 196 | if($column=='datetime'){ |
201 | 197 | return 'datetime()'; |
202 | - } |
|
203 | - elseif($column=='longtext'){ |
|
198 | + } elseif($column=='longtext'){ |
|
204 | 199 | return 'longtext()'; |
205 | - } |
|
206 | - elseif($column=='date'){ |
|
200 | + } elseif($column=='date'){ |
|
207 | 201 | return 'date()'; |
208 | - } |
|
209 | - elseif($column=='text'){ |
|
202 | + } elseif($column=='text'){ |
|
210 | 203 | return 'text()'; |
211 | - } |
|
212 | - elseif($column=='timestamp'){ |
|
204 | + } elseif($column=='timestamp'){ |
|
213 | 205 | return 'timestamp()'; |
214 | - } |
|
215 | - elseif($column=='mediumint'){ |
|
206 | + } elseif($column=='mediumint'){ |
|
216 | 207 | return 'mediumint()'; |
217 | - } |
|
218 | - elseif($column=='tinyint'){ |
|
208 | + } elseif($column=='tinyint'){ |
|
219 | 209 | return 'tinyint()'; |
220 | - } |
|
221 | - elseif($column=='float'){ |
|
210 | + } elseif($column=='float'){ |
|
222 | 211 | return 'float()'; |
223 | - } |
|
224 | - elseif($column=='mediumtext'){ |
|
212 | + } elseif($column=='mediumtext'){ |
|
225 | 213 | return 'mediumtext()'; |
226 | - } |
|
227 | - elseif($column=='mediumblob'){ |
|
214 | + } elseif($column=='mediumblob'){ |
|
228 | 215 | return 'mediumblob()'; |
229 | - } |
|
230 | - elseif($column=='blob'){ |
|
216 | + } elseif($column=='blob'){ |
|
231 | 217 | return 'blob()'; |
232 | - } |
|
233 | - elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
218 | + } elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
234 | 219 | return 'enum(['.$enum[1].'])'; |
235 | - } |
|
236 | - else{ |
|
220 | + } else{ |
|
237 | 221 | return $column; |
238 | 222 | } |
239 | 223 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param ApplicationContracts $app |
19 | 19 | * @param null|object $route |
20 | 20 | */ |
21 | - public function __construct(ApplicationContracts $app, $route=null) |
|
21 | + public function __construct(ApplicationContracts $app, $route = null) |
|
22 | 22 | { |
23 | 23 | parent::__construct($app); |
24 | 24 | |
@@ -34,53 +34,53 @@ discard block |
||
34 | 34 | { |
35 | 35 | $routes = $this->route->getRoutes(); |
36 | 36 | |
37 | - if(!isset($routes['pattern'])){ |
|
37 | + if (!isset($routes['pattern'])) { |
|
38 | 38 | return []; |
39 | 39 | } |
40 | 40 | |
41 | 41 | $patterns = $routes['pattern']; |
42 | - $urlRoute = array_filter(route(),'strlen'); |
|
42 | + $urlRoute = array_filter(route(), 'strlen'); |
|
43 | 43 | |
44 | 44 | $patternList = []; |
45 | 45 | |
46 | - foreach($routes['data'] as $patternKey=>$routeData){ |
|
47 | - if($routeData['http']==httpMethod()){ |
|
48 | - $patternList[$patternKey]=$patterns[$patternKey]; |
|
46 | + foreach ($routes['data'] as $patternKey=>$routeData) { |
|
47 | + if ($routeData['http']==httpMethod()) { |
|
48 | + $patternList[$patternKey] = $patterns[$patternKey]; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | 52 | $scoredList = []; |
53 | 53 | |
54 | - foreach ($patternList as $key=>$pattern){ |
|
54 | + foreach ($patternList as $key=>$pattern) { |
|
55 | 55 | |
56 | 56 | $patternCount = $this->getPatternRealCount($pattern); |
57 | 57 | |
58 | - if(count($urlRoute)==0 && count($urlRoute)==0) return array_key_first($patternList); |
|
58 | + if (count($urlRoute)==0 && count($urlRoute)==0) return array_key_first($patternList); |
|
59 | 59 | |
60 | - if(isset($patternCount['optional'])){ |
|
61 | - $optionalCount = count($patternCount['default']) + count($patternCount['optional']); |
|
60 | + if (isset($patternCount['optional'])) { |
|
61 | + $optionalCount = count($patternCount['default'])+count($patternCount['optional']); |
|
62 | 62 | } |
63 | 63 | |
64 | - if(count($urlRoute) == count($patternCount['default']) || |
|
64 | + if (count($urlRoute)==count($patternCount['default']) || |
|
65 | 65 | (isset($optionalCount) && count($urlRoute)>count($patternCount['default']) && $optionalCount>=count($urlRoute)) |
66 | - ){ |
|
66 | + ) { |
|
67 | 67 | |
68 | - foreach ($pattern as $pkey=>$item){ |
|
68 | + foreach ($pattern as $pkey=>$item) { |
|
69 | 69 | |
70 | - if($this->route->isMatchVaribleRegexPattern($item)===false){ |
|
71 | - if(isset($urlRoute[$pkey]) && $urlRoute[$pkey]==$item){ |
|
70 | + if ($this->route->isMatchVaribleRegexPattern($item)===false) { |
|
71 | + if (isset($urlRoute[$pkey]) && $urlRoute[$pkey]==$item) { |
|
72 | 72 | $scoredList[$key][] = 3; |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - if($this->route->isMatchVaribleRegexPattern($item) && !$this->route->isOptionalVaribleRegexPattern($item)){ |
|
77 | - if(isset($urlRoute[$pkey])){ |
|
76 | + if ($this->route->isMatchVaribleRegexPattern($item) && !$this->route->isOptionalVaribleRegexPattern($item)) { |
|
77 | + if (isset($urlRoute[$pkey])) { |
|
78 | 78 | $scoredList[$key][] = 2; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - if($this->route->isMatchVaribleRegexPattern($item) && $this->route->isOptionalVaribleRegexPattern($item)){ |
|
83 | - if(isset($urlRoute[$pkey])){ |
|
82 | + if ($this->route->isMatchVaribleRegexPattern($item) && $this->route->isOptionalVaribleRegexPattern($item)) { |
|
83 | + if (isset($urlRoute[$pkey])) { |
|
84 | 84 | $scoredList[$key][] = 1; |
85 | 85 | } |
86 | 86 | } |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | $list = []; |
105 | 105 | $list['default'] = []; |
106 | 106 | |
107 | - foreach ($pattern as $key=>$value){ |
|
108 | - if(($this->route->isMatchVaribleRegexPattern($value)===false) || ($this->route->isMatchVaribleRegexPattern($value) |
|
109 | - && !$this->route->isOptionalVaribleRegexPattern($value))){ |
|
107 | + foreach ($pattern as $key=>$value) { |
|
108 | + if (($this->route->isMatchVaribleRegexPattern($value)===false) || ($this->route->isMatchVaribleRegexPattern($value) |
|
109 | + && !$this->route->isOptionalVaribleRegexPattern($value))) { |
|
110 | 110 | $list['default'][$key] = $value; |
111 | 111 | } |
112 | 112 | |
113 | - if(($this->route->isMatchVaribleRegexPattern($value) |
|
114 | - && $this->route->isOptionalVaribleRegexPattern($value))){ |
|
113 | + if (($this->route->isMatchVaribleRegexPattern($value) |
|
114 | + && $this->route->isOptionalVaribleRegexPattern($value))) { |
|
115 | 115 | $list['optional'][] = true; |
116 | 116 | } |
117 | 117 | } |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | * @param array $scoredList |
126 | 126 | * @return false|int|string |
127 | 127 | */ |
128 | - private function showKeyAccordingToScoredList($scoredList=array()) |
|
128 | + private function showKeyAccordingToScoredList($scoredList = array()) |
|
129 | 129 | { |
130 | 130 | $scored = []; |
131 | 131 | |
132 | - foreach($scoredList as $key=>$item){ |
|
132 | + foreach ($scoredList as $key=>$item) { |
|
133 | 133 | $scored[$key] = array_sum($item); |
134 | 134 | } |
135 | 135 | |
136 | - if(count($scored)){ |
|
137 | - return array_search(max($scored),$scored); |
|
136 | + if (count($scored)) { |
|
137 | + return array_search(max($scored), $scored); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return null; |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | $route = route(); |
153 | 153 | |
154 | 154 | foreach ($pattern as $key=>$item) { |
155 | - if($this->route->isMatchVaribleRegexPattern($item)===false){ |
|
156 | - if(isset($route[$key]) && $item!==$route[$key]){ |
|
155 | + if ($this->route->isMatchVaribleRegexPattern($item)===false) { |
|
156 | + if (isset($route[$key]) && $item!==$route[$key]) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | } |
@@ -55,7 +55,9 @@ |
||
55 | 55 | |
56 | 56 | $patternCount = $this->getPatternRealCount($pattern); |
57 | 57 | |
58 | - if(count($urlRoute)==0 && count($urlRoute)==0) return array_key_first($patternList); |
|
58 | + if(count($urlRoute)==0 && count($urlRoute)==0) { |
|
59 | + return array_key_first($patternList); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | if(isset($patternCount['optional'])){ |
61 | 63 | $optionalCount = count($patternCount['default']) + count($patternCount['optional']); |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | * @param null|string $method |
37 | 37 | * @return array |
38 | 38 | */ |
39 | - public static function getRoutes($method=null) : array |
|
39 | + public static function getRoutes($method = null) : array |
|
40 | 40 | { |
41 | 41 | // it collects and |
42 | 42 | // executes route data in an array. |
43 | - if(is_null($method)){ |
|
43 | + if (is_null($method)) { |
|
44 | 44 | return static::$routes; |
45 | 45 | } |
46 | 46 | |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | |
49 | 49 | $routes = self::getRoutes(); |
50 | 50 | |
51 | - if(isset($routes['data'])){ |
|
52 | - foreach ($routes['data'] as $key=>$item){ |
|
53 | - if($item['http']==httpMethod()){ |
|
51 | + if (isset($routes['data'])) { |
|
52 | + foreach ($routes['data'] as $key=>$item) { |
|
53 | + if ($item['http']==httpMethod()) { |
|
54 | 54 | $httpRouteList['data'][$key] = $item; |
55 | 55 | } |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - if(isset($routes['pattern'],$httpRouteList['data'])){ |
|
60 | - foreach ($httpRouteList['data'] as $key=>$item){ |
|
59 | + if (isset($routes['pattern'], $httpRouteList['data'])) { |
|
60 | + foreach ($httpRouteList['data'] as $key=>$item) { |
|
61 | 61 | $httpRouteList['pattern'][$key] = $routes['pattern'][$key]; |
62 | 62 | } |
63 | 63 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | // detects where the route path is coming from |
76 | 76 | // and returns this data in the static path. |
77 | - $trace = Utils::trace(2,'file'); |
|
77 | + $trace = Utils::trace(2, 'file'); |
|
78 | 78 | |
79 | 79 | // the trace is returned if the variable is available |
80 | 80 | // in the path data, otherwise it returns null. |