Completed
Push — master ( cf838f...441ca2 )
by Dmitry
04:31
created

OpenvzPackage::getLocations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
namespace hipanel\modules\server\models;
4
5
use Yii;
6
7
/**
8
 * Class OpenvzPackage
9
 * @property string $name
10
 */
11
class OpenvzPackage extends Package
12
{
13
    protected function getResourceValue_cpu()
14
    {
15
        $part = $this->getPartByType('cpu');
16
        preg_match('/((\d+) MHz)$/i', $part->partno, $matches);
17
        return Yii::t('hipanel/server', '{0, number} MHz', $matches[2]);
0 ignored issues
show
Documentation introduced by
$matches[2] is of type string, but the function expects a array.

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...
18
    }
19
20
    protected function getResourceTitle_hdd()
21
    {
22
        return Yii::t('hipanel/server', 'HDD + SSD cache');
23
    }
24
25
    /** @inheritdoc */
26
    public function getLocations()
27
    {
28
        return [
29
            3 => Yii::t('hipanel/server', 'Netherlands, Amsterdam'),
30
            2 => Yii::t('hipanel/server', 'USA, Ashburn'),
31
        ];
32
    }
33
}
34