ServerUse   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A formName() 0 3 1
A getBandwidthTypes() 0 3 1
A tableName() 0 3 1
A getDisplayAmount() 0 9 3
A getTrafficTypes() 0 3 1
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\models;
12
13
use hipanel\modules\finance\models\RUse;
14
15
class ServerUse extends RUse
16
{
17
    use \hipanel\base\ModelTrait;
18
19
    public function formName()
20
    {
21
        return 'ServerUse';
22
    }
23
24
    public static function tableName()
25
    {
26
        return 'server';
27
    }
28
29
    private function getTrafficTypes()
30
    {
31
        return ['server_traf_in', 'server_traf_max', 'server_traf'];
32
    }
33
34
    private function getBandwidthTypes()
35
    {
36
        return ['server_traf95_in', 'server_traf95_max', 'server_traf95'];
37
    }
38
39
    public function getDisplayAmount()
40
    {
41
        if (in_array($this->type, $this->getBandwidthTypes(), true)) {
0 ignored issues
show
Bug Best Practice introduced by
The property type does not exist on hipanel\modules\server\models\ServerUse. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
            return round($this->last / pow(10, 6), 2);
0 ignored issues
show
Bug Best Practice introduced by
The property last does not exist on hipanel\modules\server\models\ServerUse. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
        } elseif (in_array($this->type, $this->getTrafficTypes(), true)) {
44
            return round($this->total / pow(10, 9), 2);
0 ignored issues
show
Bug Best Practice introduced by
The property total does not exist on hipanel\modules\server\models\ServerUse. Since you implemented __get, consider adding a @property annotation.
Loading history...
45
        }
46
47
        return $this->total;
48
    }
49
}
50