Completed
Pull Request — master (#3)
by ARCANEDEV
03:48 queued 01:31
created

RouteServiceProvider::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php namespace Arcanesoft\Blog\Providers;
2
3
use Arcanesoft\Blog\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\Blog\Providers
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class RouteServiceProvider extends ServiceProvider
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Main Functions
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Define the routes for the application.
21
     *
22
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
23
     */
24 6
    public function map(Router $router)
25
    {
26 6
        $this->mapPublicRoutes($router);
0 ignored issues
show
Unused Code introduced by
The call to the method Arcanesoft\Blog\Provider...ider::mapPublicRoutes() 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...
27 6
        $this->mapAdminRoutes($router);
28 6
    }
29
30
    /**
31
     * Define the public routes for the application.
32
     *
33
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
34
     */
35 6
    private function mapPublicRoutes(Router $router)
0 ignored issues
show
Unused Code introduced by
The parameter $router is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        //
38 6
    }
39
40
    /**
41
     * Define the foundation routes for the application.
42
     *
43
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
44
     */
45 6
    private function mapAdminRoutes(Router $router)
46
    {
47 6
        $attributes = $this->getAdminAttributes(
48 6
            'blog.',
49 6
            'Arcanesoft\\Blog\\Http\\Controllers\\Admin',
50 6
            $this->config()->get('arcanesoft.blog.route.prefix', 'blog')
51 2
        );
52
53 6
        $router->group($attributes, function (Router $router) {
54 6
            Routes\Admin\StatsRoutes::register($router);
55 6
            Routes\Admin\PostsRoutes::register($router);
56 6
            Routes\Admin\CommentsRoutes::register($router);
57 6
            Routes\Admin\CategoriesRoutes::register($router);
58 6
            Routes\Admin\TagsRoutes::register($router);
59 6
        });
60 6
    }
61
}
62