Passed
Push — master ( 207765...57309d )
by Rutger
03:12
created

Oauth2ListClientsAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 2
b 0
f 0
dl 0
loc 19
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 2
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\controllers\console\client;
4
5
use rhertogh\Yii2Oauth2Server\controllers\console\base\traits\GenerateClientsTableTrait;
6
use rhertogh\Yii2Oauth2Server\controllers\console\Oauth2ClientController;
7
use yii\base\Action;
8
use yii\console\ExitCode;
9
10
/**
11
 * @property Oauth2ClientController $controller
12
 */
13
class Oauth2ListClientsAction extends Action
14
{
15
    use GenerateClientsTableTrait;
16
17
    public function run()
18
    {
19
        $module = $this->controller->module;
20
21
        $clients = $module->getClientRepository()->getAllClients();
22
23
        if (!$clients) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $clients of type rhertogh\Yii2Oauth2Serve...Oauth2ClientInterface[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
24
            $this->controller->stdout('No clients defined. Run `yii '
25
                . $this->controller->uniqueId . '/create` to define one.' . PHP_EOL);
26
            return ExitCode::OK;
27
        }
28
29
        $this->controller->stdout($this->generateClientsTable($clients));
30
31
        return ExitCode::OK;
32
    }
33
}
34