Completed
Push — master ( 4a002f...a1b70a )
by Ezra
13s queued 10s
created

Level   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 30
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
1
<?php
2
3
namespace Syntax\SteamApi\Containers\Player;
4
5
class Level
6
{
7
    public $playerXp;
8
9
    public $playerLevel;
10
11
    public $xpToLevelUp;
12
13
    public $xpForCurrentLevel;
14
15
    public $currentLevelFloor;
16
17
    public $currentLevelCeiling;
18
19
    public $percentThroughLevel;
20
21
    public function __construct($levelDetails)
22
    {
23
        $this->playerXp          = $levelDetails->player_xp;
24
        $this->playerLevel       = $levelDetails->player_level;
25
        $this->xpToLevelUp       = $levelDetails->player_xp_needed_to_level_up;
26
        $this->xpForCurrentLevel = $levelDetails->player_xp_needed_current_level;
27
28
        $this->currentLevelFloor   = $this->xpForCurrentLevel;
29
        $this->currentLevelCeiling = $this->playerXp + $this->xpToLevelUp;
30
31
        // arbitrary range formula. n = value in the middle ( n - min ) / ( max - min ) * 100
32
        $this->percentThroughLevel = ($this->playerXp - $this->currentLevelFloor) / ($this->currentLevelCeiling - $this->currentLevelFloor) * 100;
33
    }
34
}
35