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

Oauth2DeleteClientAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 10
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 18 3
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\controllers\console\client;
4
5
use rhertogh\Yii2Oauth2Server\controllers\console\client\base\Oauth2BaseClientAction;
6
use rhertogh\Yii2Oauth2Server\controllers\console\Oauth2ClientController;
7
use rhertogh\Yii2Oauth2Server\interfaces\models\Oauth2ClientInterface;
8
use rhertogh\Yii2Oauth2Server\Oauth2Module;
9
use yii\console\ExitCode;
10
use yii\console\widgets\Table;
11
use yii\helpers\Console;
12
13
/**
14
 * @property Oauth2ClientController $controller
15
 */
16
class Oauth2DeleteClientAction extends Oauth2BaseClientAction
17
{
18
    public function run($id)
19
    {
20
        $controller = $this->controller;
21
        $client = $this->findByIdOrIdentifier($id);
22
23
        $clientInfo = implode('-', $client->getPrimaryKey(true)) . ' (' . $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

23
        $clientInfo = implode('-', $client->getPrimaryKey(true)) . ' (' . $client->/** @scrutinizer ignore-call */ getIdentifier() . ')';
Loading history...
24
25
        if (
26
            $controller->confirm('Are you sure you want to delete Client ' . $clientInfo
27
                . '? This action can not be undone!')
28
        ) {
29
            $client->delete();
30
            if ($controller->verbose) {
31
                $controller->stdout('Deleted Client ' . $clientInfo . PHP_EOL, Console::FG_GREEN);
32
            }
33
        }
34
35
        return ExitCode::OK;
36
    }
37
}
38