TagController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 4 1
A create() 0 4 1
A store() 0 6 1
A findByName() 0 4 1
1
<?php namespace Modules\Blog\Http\Controllers\Api;
2
3
use Illuminate\Routing\Controller;
4
use Illuminate\Support\Facades\App;
5
use Illuminate\Support\Facades\Response;
6
use Modules\Blog\Http\Requests\CreateTagRequest;
7
use Modules\Blog\Repositories\TagRepository;
8
9
class TagController extends Controller
10
{
11
    /**
12
     * @var TagRepository
13
     */
14
    private $tag;
15
16
    public function __construct(TagRepository $tag)
17
    {
18
        $this->tag = $tag;
19
    }
20
21
    /**
22
     * Display a listing of the resource.
23
     *
24
     * @return Response
25
     */
26
    public function index()
27
    {
28
        return $this->tag->all();
29
    }
30
31
    /**
32
     * Show the form for creating a new resource.
33
     *
34
     * @return Response
35
     */
36
    public function create()
37
    {
38
        return \View::make('collection.create');
39
    }
40
41
    /**
42
     * Store a newly created resource in storage.
43
     *
44
     * @param  CreateTagRequest $request
45
     * @return Response
46
     */
47
    public function store(CreateTagRequest $request)
48
    {
49
        $tag = $this->tag->createForLanguage(App::getLocale(), $request->name);
50
51
        return Response::json($tag);
52
    }
53
54
    /**
55
     * Find the resource by name
56
     *
57
     * @param $name
58
     * @return Response
59
     */
60
    public function findByName($name)
61
    {
62
        return Response::json($this->tag->findByName($name));
63
    }
64
}
65