@@ -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. |