Completed
Push — master ( 434bf1...28f331 )
by Phecho
03:35
created

CommentController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getComments() 0 4 1
A getComment() 0 4 1
A postComments() 0 16 2
1
<?php
2
3
namespace Gitamin\Http\Controllers\Api;
4
5
use Gitamin\Commands\Comment\AddCommentCommand;
6
use Gitamin\Models\Comment;
7
use GrahamCampbell\Binput\Facades\Binput;
8
use Illuminate\Contracts\Auth\Guard;
9
use Illuminate\Database\QueryException;
10
use Illuminate\Foundation\Bus\DispatchesJobs;
11
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
12
13
class CommentController extends AbstractApiController
14
{
15
    use DispatchesJobs;
16
17
    public function getComments()
18
    {
19
        echo 'getComments';
20
    }
21
22
    public function getComment(Comment $comment)
0 ignored issues
show
Unused Code introduced by
The parameter $comment 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...
23
    {
24
        echo 'getComment';
25
    }
26
27
    /**
28
     * Create a new comment.
29
     *
30
     * @param \Illuminate\Contracts\Auth\Guard $auth
31
     *
32
     * @return \Illuminate\Http\JsonResponse
33
     */
34
    public function postComments(Guard $auth)
0 ignored issues
show
Unused Code introduced by
The parameter $auth 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...
35
    {
36
        try {
37
            $comment = $this->dispatch(new AddCommentCommand(
38
                Binput::get('message'),
39
                Binput::get('target_type'),
40
                Binput::get('target_id'),
41
                Binput::get('author_id'),
42
                Binput::get('project_id')
43
            ));
44
        } catch (QueryException $e) {
45
            throw new BadRequestHttpException();
46
        }
47
48
        return $this->item($comment);
49
    }
50
}
51