Completed
Push — master ( eee4fb...7643b1 )
by ARCANEDEV
11:35
created

RouteServiceProvider::mapBackEndRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
ccs 12
cts 12
cp 1
cc 1
eloc 10
nc 1
nop 1
crap 1
1
<?php namespace Arcanesoft\Pages\Providers;
2
3
use Arcanesoft\Pages\Http\Routes;
4
use Arcanesoft\Core\Bases\RouteServiceProvider as ServiceProvider;
5
use Illuminate\Contracts\Routing\Registrar as Router;
6
7
/**
8
 * Class     RouteServiceProvider
9
 *
10
 * @package  Arcanesoft\Pages\Providers
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class RouteServiceProvider extends ServiceProvider
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Getters & Setters
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Get the routes namespace
21
     *
22
     * @return string
23
     */
24
    protected function getRouteNamespace()
25
    {
26
        return 'Arcanesoft\\Pages\\Http\\Routes';
27
    }
28
29
    /**
30
     * Get the auth foundation route prefix.
31
     *
32
     * @return string
33
     */
34 8
    public function getFoundationPagesPrefix()
35
    {
36 8
        $prefix = array_get($this->getFoundationRouteGroup(), 'prefix', 'dashboard');
37
38 8
        return "$prefix/" . config('arcanesoft.pages.route.prefix', 'pages');
39
    }
40
41
    /* ------------------------------------------------------------------------------------------------
42
     |  Main Functions
43
     | ------------------------------------------------------------------------------------------------
44
     */
45
    /**
46
     * Define the routes for the application.
47
     *
48
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
49
     */
50 8
    public function map(Router $router)
51
    {
52 8
        $this->mapFrontEndRoutes($router);
0 ignored issues
show
Unused Code introduced by
The call to the method Arcanesoft\Pages\Provide...er::mapFrontEndRoutes() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
53 8
        $this->mapBackEndRoutes($router);
54 8
    }
55
56
    /**
57
     * Define the public routes for the application.
58
     *
59
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
60
     */
61 8
    private function mapFrontEndRoutes(Router $router)
62
    {
63
        $attributes = [
0 ignored issues
show
Unused Code introduced by
$attributes is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
64 8
            'prefix'    => 'pages',
65 6
            'as'        => 'pages::',
66 6
            'namespace' => 'Arcanesoft\\Pages\\Http\\Controllers\\Front',
67 6
        ];
68 8
    }
69
    /**
70
     * Define the foundation routes for the application.
71
     *
72
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
73
     */
74 8
    private function mapBackEndRoutes(Router $router)
75
    {
76 8
        $attributes = array_merge($this->getFoundationRouteGroup(), [
77 8
            'as'        => 'pages::foundation.',
78 6
            'namespace' => 'Arcanesoft\\Pages\\Http\\Controllers\\Back',
79 6
        ]);
80
81 8
        $router->group(array_merge(
82 6
            $attributes,
83 8
            ['prefix' => $this->getFoundationPagesPrefix()]
84 8
        ), function (Router $router) {
85 8
            Routes\Back\StatsRoutes::register($router);
86 8
            Routes\Back\PagesRoutes::register($router);
87 8
        });
88
    }
89
}
90