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

OpenvzPackage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 23
ccs 0
cts 10
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getResourceValue_cpu() 0 6 1
A getResourceTitle_hdd() 0 4 1
A getLocations() 0 7 1
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