Ip2LocationController::actionUpdate()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 9
ccs 0
cts 9
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace slavkluev\Ip2Location\commands;
6
7
use Yii;
8
use yii\console\Controller;
9
use yii\console\ExitCode;
10
use yii\helpers\Console;
11
12
class Ip2LocationController extends Controller
13
{
14
    public $defaultAction = 'update';
15
16
    /**
17
     * Updates and reloads the database.
18
     */
19
    public function actionUpdate()
20
    {
21
        try {
22
            Yii::$app->ip2location->update();
0 ignored issues
show
Bug introduced by
The method update() does not exist on null. ( Ignorable by Annotation )

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

22
            Yii::$app->ip2location->/** @scrutinizer ignore-call */ 
23
                                    update();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
            $this->stdout('Database was updated successfully.', Console::FG_GREEN);
24
            return ExitCode::OK;
25
        } catch (\Exception $exception) {
26
            $this->stderr($exception->getMessage(), Console::FG_RED);
27
            return ExitCode::UNSPECIFIED_ERROR;
28
        }
29
    }
30
}
31