Completed
Pull Request — master (#47)
by Phecho
04:02
created

NoteController   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 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 38
rs 10

3 Methods

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