Completed
Push — master ( 2ccb51...4b9a6b )
by ARCANEDEV
02:56
created

PostsRoutes::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 65
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 51
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 65
ccs 51
cts 52
cp 0.9808
rs 9.3571
cc 1
eloc 40
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace Arcanesoft\Blog\Http\Routes\Foundation;
2
3
use Arcanedev\Support\Bases\RouteRegister;
4
use Arcanesoft\Blog\Models\Post;
5
use Illuminate\Contracts\Routing\Registrar;
6
7
/**
8
 * Class     PostsRoutes
9
 *
10
 * @package  Arcanesoft\Blog\Http\Routes\Foundation
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class PostsRoutes extends RouteRegister
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Main Functions
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Map routes.
21
     *
22
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
23
     */
24 8
    public function map(Registrar $router)
25
    {
26 8
        $this->group([
27 8
            'prefix'    => 'posts',
28 6
            'as'        => 'posts.',
29
        ], function () {
30 8
            $this->get('/', [
31 8
                'as'   => 'index',         // blog::foundation.posts.index
32 6
                'uses' => 'PostsController@index',
33 6
            ]);
34
35 8
            $this->get('trashed', [
36 8
                'as'   => 'trash',         // blog::foundation.posts.trash
37 6
                'uses' => 'PostsController@trash',
38 6
            ]);
39
40 8
            $this->get('create', [
41 8
                'as'   => 'create',        // blog::foundation.posts.create
42 6
                'uses' => 'PostsController@create',
43 6
            ]);
44
45 8
            $this->post('store', [
46 8
                'as'   => 'store',         // blog::foundation.posts.store
47 6
                'uses' => 'PostsController@store',
48 6
            ]);
49
50 8
            $this->group([
51 8
                'prefix' => '{blog_post_id}',
52
            ], function () {
53 8
                $this->get('show', [
54 8
                    'as'   => 'show',      // blog::foundation.posts.show
55 6
                    'uses' => 'PostsController@show',
56 6
                ]);
57
58 8
                $this->get('edit', [
59 8
                    'as'   => 'edit',      // blog::foundation.posts.edit
60 6
                    'uses' => 'PostsController@edit',
61 6
                ]);
62
63 8
                $this->put('update', [
64 8
                    'as'   => 'update',    // blog::foundation.posts.update
65 6
                    'uses' => 'PostsController@update',
66 6
                ]);
67
68 8
                $this->put('publish', [
69 8
                    'as'   => 'publish',   // blog::foundation.posts.activate
70 6
                    'uses' => 'PostsController@publish',
71 6
                ]);
72
73 8
                $this->put('restore', [
74 8
                    'as'   => 'restore',   // blog::foundation.posts.restore
75 6
                    'uses' => 'PostsController@restore',
76 6
                ]);
77
78 8
                $this->delete('delete', [
79 8
                    'as'   => 'delete',    // blog::foundation.posts.delete
80 6
                    'uses' => 'PostsController@delete',
81 6
                ]);
82 8
            });
83 8
        });
84
85 8
        $this->bind('blog_post_id', function($postId) {
0 ignored issues
show
Bug introduced by
The method bind() does not seem to exist on object<Arcanesoft\Blog\H...Foundation\PostsRoutes>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
86
            return Post::findOrFail($postId);
87 8
        });
88 8
    }
89
}
90