Completed
Push — master ( eb2586...ec2395 )
by Sherif
01:59
created

OauthClientController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Modules\Acl\Http\Controllers;
4
5
use App\Modules\Core\BaseClasses\BaseApiController;
6
use App\Modules\Acl\Repositories\OauthClientRepository;
7
use App\Modules\Core\Utl\CoreConfig;
8
use App\Modules\Core\Http\Resources\General as GeneralResource;
9
use App\Modules\Acl\Http\Requests\InsertOauthClient;
10
use App\Modules\Acl\Http\Requests\UpdateOauthClient;
11
12
class OauthClientController extends BaseApiController
13
{
14
    /**
15
     * Init new object.
16
     *
17
     * @param   OauthClientRepository $repo
18
     * @param   CoreConfig            $config
19
     * @return  void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
     */
21
    public function __construct(OauthClientRepository $repo, CoreConfig $config)
22
    {
23
        parent::__construct($repo, $config, 'App\Modules\Acl\Http\Resources\OauthClient');
24
    }
25
26
    /**
27
     * Insert the given model to storage.
28
     *
29
     * @param InsertOauthClient $request
30
     * @return \Illuminate\Http\Response
31
     */
32
    public function insert(InsertOauthClient $request)
33
    {
34
        return new $this->modelResource($this->repo->save($request->all()));
35
    }
36
37
    /**
38
     * Update the given model to storage.
39
     *
40
     * @param UpdateOauthClient $request
41
     * @return \Illuminate\Http\Response
42
     */
43
    public function update(UpdateOauthClient $request)
44
    {
45
        return new $this->modelResource($this->repo->save($request->all()));
46
    }
47
48
    /**
49
     * Revoke the given client.
50
     *
51
     * @param  integer  $clientId Id of the client
52
     * @return \Illuminate\Http\Response
53
     */
54
    public function revoke($clientId)
55
    {
56
        return new GeneralResource($this->repo->revoke($clientId));
57
    }
58
59
    /**
60
     * Un revoke the given client.
61
     *
62
     * @param  integer  $clientId Id of the client
63
     * @return \Illuminate\Http\Response
64
     */
65
    public function unRevoke($clientId)
66
    {
67
        return new GeneralResource($this->repo->unRevoke($clientId));
68
    }
69
}
70