ApplicationController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
c 0
b 0
f 0
cc 1
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Modules\Application\Http\Controllers;
4
5
use Foundation\Abstracts\Controller\Controller;
6
use Foundation\Responses\ApiResponse;
7
use Illuminate\Http\Request;
8
use Modules\Application\Contracts\ApplicationServiceContract;
9
use Modules\Application\Transformers\ApplicationTransformer;
10
11
class ApplicationController extends Controller
12
{
13
    /**
14
     * @var ApplicationServiceContract
15
     */
16
    protected $service;
17
18
    /**
19
     * ApplicationController constructor.
20
     *
21
     * @param $service
22
     */
23
    public function __construct(ApplicationServiceContract $service)
24
    {
25
        $this->service = $service;
26
    }
27
28
    /**
29
     * Display a listing of the resource.
30
     */
31
    public function index()
32
    {
33
        return ApplicationTransformer::collection($this->service->getByUserId(get_authenticated_user_id()));
0 ignored issues
show
Bug introduced by
The method getByUserId() does not exist on Modules\Application\Cont...licationServiceContract. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        return ApplicationTransformer::collection($this->service->/** @scrutinizer ignore-call */ getByUserId(get_authenticated_user_id()));

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...
34
    }
35
36
    /**
37
     * Store a newly created Application in storage.
38
     */
39
    public function store(Request $request)
40
    {
41
        $Application = $this->service->create($this->injectUserId($request));
0 ignored issues
show
Bug introduced by
The method create() does not exist on Modules\Application\Cont...licationServiceContract. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        /** @scrutinizer ignore-call */ 
42
        $Application = $this->service->create($this->injectUserId($request));

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...
42
43
        return ApplicationTransformer::resource($Application);
44
    }
45
46
    /**
47
     * Update a Application.
48
     *
49
     * @param Request $request
50
     */
51
    public function update(Request $request, $id)
52
    {
53
        $Application = $this->service->find($id);
0 ignored issues
show
Bug introduced by
The method find() does not exist on Modules\Application\Cont...licationServiceContract. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        /** @scrutinizer ignore-call */ 
54
        $Application = $this->service->find($id);

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...
54
55
        $this->exists($Application);
56
        $this->hasAccess($Application);
57
        $Application = $this->service->update($id, $request->toArray());
0 ignored issues
show
Bug introduced by
The method update() does not exist on Modules\Application\Cont...licationServiceContract. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
        /** @scrutinizer ignore-call */ 
58
        $Application = $this->service->update($id, $request->toArray());

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...
58
59
        return ApplicationTransformer::resource($Application);
60
    }
61
62
    /**
63
     * Show the specified resource.
64
     */
65
    public function show($id)
66
    {
67
        $Application = $this->service->find($id);
68
69
        $this->exists($Application);
70
        $this->hasAccess($Application);
71
72
        return ApplicationTransformer::resource($Application);
73
    }
74
75
    /**
76
     * Remove the specified resource from storage.
77
     */
78
    public function destroy($id)
79
    {
80
        $Application = $this->service->find($id);
81
82
        $this->exists($Application);
83
        $this->hasAccess($Application);
84
85
        $this->service->delete($Application);
0 ignored issues
show
Bug introduced by
The method delete() does not exist on Modules\Application\Cont...licationServiceContract. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

85
        $this->service->/** @scrutinizer ignore-call */ 
86
                        delete($Application);

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
87
        return ApiResponse::deleted();
88
    }
89
}
90