Completed
Push — Laravel4 ( 02d48b...8c5149 )
by Travis
03:47 queued 03:02
created

Level   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 1
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 31
rs 10

1 Method

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