Completed
Push — master ( 43d6b6...7fd3dc )
by Sherif
12:33
created

OauthClientRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 4 1
A revoke() 0 6 1
A regenerateSecret() 0 4 1
1
<?php namespace App\Modules\V1\Acl\Repositories;
2
3
use App\Modules\V1\Core\AbstractRepositories\AbstractRepository;
4
5
class OauthClientRepository extends AbstractRepository
6
{
7
	/**
8
	 * Return the model full namespace.
9
	 * 
10
	 * @return string
11
	 */
12
	protected function getModel()
13
	{
14
		return 'App\Modules\V1\Acl\OauthClient';
15
	}
16
17
    /**
18
     * Revoke the given client.
19
     *
20
     * @param  integer  $clientId
21
     * @return void
22
     */
23
    public function revoke($clientId)
24
    {
25
    	$client = $this->find($clientId);
26
        $client->tokens()->update(['revoked' => true]);
27
        $client->forceFill(['revoked' => true])->save();
28
    }
29
30
    /**
31
     * Regenerate seceret for the given client.
32
     *
33
     * @param  integer  $clientId
34
     * @return void
35
     */
36
    public function regenerateSecret($clientId)
37
    {
38
		$this->update($clientId, ['secret' => str_random(40)]);
0 ignored issues
show
Documentation introduced by
$clientId is of type integer, but the function expects a object<App\Modules\V1\Co...stractRepositories\var>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
    }
40
}
41