GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f78015...839624 )
by Alireza
15s queued 11s
created

MainController   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 4
dl 0
loc 54
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B entityUrl() 0 50 9
1
<?php
2
3
/* 
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
namespace Serverfireteam\Panel;
9
10
use \Serverfireteam\Panel\libs\PanelElements;
11
use Illuminate\Routing\Controller;
12
use Illuminate\Support\Facades\Route;
13
use Illuminate\Support\Facades\Request;
14
15
class MainController extends Controller {
16
17
18
    public function entityUrl($entity, $methods){
19
        $uri = Request::path();
20
        // Get route collection
21
        $routes = collect(Route::getRoutes()->getRoutes())->reduce(function ($carry = [], $route) {
22
            starts_with($route->uri(), 'panel/{entity}') ?: $carry[] = $route;
0 ignored issues
show
Deprecated Code introduced by
The function starts_with() has been deprecated with message: Str::startsWith() should be used directly instead. Will be removed in Laravel 5.9.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
23
24
            return  $carry;
25
        });
26
        try {
27
            // If we find a match, take the user there.
28
            foreach ($routes as $route){
29
                if ($uri == $route->uri()){
30
                    $controller_path = $route->getAction()['controller'];
31
                    $controller_action = explode('@',$controller_path);
32
                    $controller = \App::make($controller_action[0]);
33
                    return $controller->callAction($controller_action[1], array());
34
                    break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
35
                }
36
            }
37
        }
38
        catch (Exception $e){
0 ignored issues
show
Bug introduced by
The class Serverfireteam\Panel\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
39
            // Otherwise, we didn't find a match so take the user to the admin page.
40
            return redirect('/panel');
41
        }
42
43
        $appHelper = new libs\AppHelper();
44
45
        if ( \Links::isMain($entity)){
46
            $controller_path = 'Serverfireteam\Panel\\'.$entity.'Controller';
47
        } else {
48
            $panel_path = \Config::get('panel.controllers');
49
            if ( isset($panel_path) ){
50
                $controller_path = '\\'.$panel_path.'\\'.$entity.'Controller';
51
            } else {
52
                $controller_path = $appHelper->getNameSpace().'Http\Controllers\\'.$entity.'Controller';
53
            }
54
        }
55
56
        try{
57
            $controller = \App::make($controller_path);
58
        }catch(\Exception $ex){
59
            throw new \Exception("Controller not found ( $controller_path ) ");
60
        }
61
        if (!method_exists($controller, $methods)){
62
            throw new \Exception('Controller does not implement the CrudController methods!');
63
        } else {
64
            return $controller->callAction($methods, array('entity' => $entity));
65
        }
66
67
    }
68
}
69
70
71