Completed
Push — master ( ec2395...0dfd17 )
by Sherif
02:09
created

OauthClientRepository::revoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php namespace App\Modules\OauthClients\Repositories;
2
3
use App\Modules\Core\BaseClasses\BaseRepository;
4
use App\Modules\OauthClients\OauthClient;
5
6
class OauthClientRepository extends BaseRepository
7
{
8
    /**
9
     * Init new object.
10
     *
11
     * @param   OauthClient $model
12
     * @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...
13
     */
14
    public function __construct(OauthClient $model)
15
    {
16
        parent::__construct($model);
17
    }
18
19
    /**
20
     * Revoke the given client.
21
     *
22
     * @param  integer  $clientId
23
     * @return void
24
     */
25
    public function revoke($clientId)
26
    {
27
        $client = $this->find($clientId);
28
        $client->tokens()->update(['revoked' => true]);
29
        $this->save(['id'=> $clientId, 'revoked' => true]);
30
    }
31
32
    /**
33
     * Un revoke the given client.
34
     *
35
     * @param  integer  $clientId
36
     * @return void
37
     */
38
    public function unRevoke($clientId)
39
    {
40
        $this->save(['id'=> $clientId, 'revoked' => false]);
41
    }
42
}
43