Passed
Push — master ( f52d5c...0b49e9 )
by Rutger
03:13
created

Oauth2UpdateClientAction::run()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 16
ccs 0
cts 11
cp 0
rs 9.9332
cc 4
nc 2
nop 1
crap 20
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\controllers\console\client;
4
5
use League\OAuth2\Server\Grant\GrantTypeInterface;
6
use rhertogh\Yii2Oauth2Server\controllers\console\client\base\Oauth2BaseEditClientAction;
7
use rhertogh\Yii2Oauth2Server\controllers\console\Oauth2ClientController;
8
use rhertogh\Yii2Oauth2Server\helpers\DiHelper;
9
use rhertogh\Yii2Oauth2Server\interfaces\components\openidconnect\scope\Oauth2OidcScopeCollectionInterface;
10
use rhertogh\Yii2Oauth2Server\interfaces\models\Oauth2ClientInterface;
11
use rhertogh\Yii2Oauth2Server\Oauth2Module;
12
use Yii;
13
use yii\base\Action;
14
use yii\base\InvalidArgumentException;
15
use yii\console\ExitCode;
16
use yii\helpers\ArrayHelper;
17
use yii\helpers\Console;
18
19
/**
20
 * @property Oauth2ClientController $controller
21
 */
22
class Oauth2UpdateClientAction extends Oauth2BaseEditClientAction
23
{
24
    public function run($id)
25
    {
26
        $controller = $this->controller;
27
        $client = $this->findByIdOrIdentifier($id);
28
29
        $this->editClient($client);
30
        $clientScopes = $client->getClientScopes()->with('scope')->all();
0 ignored issues
show
Bug introduced by
The method getClientScopes() does not exist on rhertogh\Yii2Oauth2Serve...h2ActiveRecordInterface. It seems like you code against a sub-type of said class. However, the method does not exist in rhertogh\Yii2Oauth2Serve...2AuthCodeScopeInterface or rhertogh\Yii2Oauth2Serve...Oauth2AuthCodeInterface or rhertogh\Yii2Oauth2Serve...h2RefreshTokenInterface or rhertogh\Yii2Oauth2Serve...se\Oauth2TokenInterface or rhertogh\Yii2Oauth2Serve...uth2UserClientInterface or rhertogh\Yii2Oauth2Serve...cessTokenScopeInterface or rhertogh\Yii2Oauth2Serve...th2AccessTokenInterface or rhertogh\Yii2Oauth2Serve...\Oauth2EnabledInterface or rhertogh\Yii2Oauth2Serve...serClientScopeInterface or rhertogh\Yii2Oauth2Serve...th2ClientScopeInterface or rhertogh\Yii2Oauth2Serve...ls\Oauth2ScopeInterface or rhertogh\Yii2Oauth2Serve...Oauth2AuthCodeInterface or rhertogh\Yii2Oauth2Serve...h2RefreshTokenInterface or rhertogh\Yii2Oauth2Serve...th2AccessTokenInterface or rhertogh\Yii2Oauth2Serve...uth2UserClientInterface or rhertogh\Yii2Oauth2Serve...serClientScopeInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

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

30
        $clientScopes = $client->/** @scrutinizer ignore-call */ getClientScopes()->with('scope')->all();
Loading history...
Unused Code introduced by
The call to yii\db\ActiveQueryInterface::with() has too many arguments starting with 'scope'. ( Ignorable by Annotation )

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

30
        $clientScopes = $client->getClientScopes()->/** @scrutinizer ignore-call */ with('scope')->all();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
31
        $scopes = implode(' ', ArrayHelper::getColumn($clientScopes, 'scope.identifier'));
32
33
        if ($controller->interactive || $controller->verbose) {
34
            $controller->stdout('Successfully updated client with id "' . $client->getPrimaryKey()
0 ignored issues
show
Bug introduced by
Are you sure $client->getPrimaryKey() of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

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

34
            $controller->stdout('Successfully updated client with id "' . /** @scrutinizer ignore-type */ $client->getPrimaryKey()
Loading history...
35
                . '", identifier "' . $client->getIdentifier()
0 ignored issues
show
Bug introduced by
The method getIdentifier() does not exist on rhertogh\Yii2Oauth2Serve...h2ActiveRecordInterface. It seems like you code against a sub-type of said class. However, the method does not exist in rhertogh\Yii2Oauth2Serve...2AuthCodeScopeInterface or rhertogh\Yii2Oauth2Serve...se\Oauth2TokenInterface or rhertogh\Yii2Oauth2Serve...uth2UserClientInterface or rhertogh\Yii2Oauth2Serve...cessTokenScopeInterface or rhertogh\Yii2Oauth2Serve...\Oauth2EnabledInterface or rhertogh\Yii2Oauth2Serve...serClientScopeInterface or rhertogh\Yii2Oauth2Serve...th2ClientScopeInterface or rhertogh\Yii2Oauth2Serve...uth2UserClientInterface or rhertogh\Yii2Oauth2Serve...serClientScopeInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

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

35
                . '", identifier "' . $client->/** @scrutinizer ignore-call */ getIdentifier()
Loading history...
36
                . '"' . ($scopes ? (' and scopes "' . $scopes . '"') : '') . '.' . PHP_EOL, Console::FG_GREEN);
37
        }
38
39
        return ExitCode::OK;
40
    }
41
}
42