Skip to content

Commit bdf3b8f

Browse files
Travis BlasingameTravis Blasingame
authored andcommitted
Merge branch 'Laravel4' of github.com:syntaxerrors/Steam into Laravel4
2 parents 48dc7ef + 7ba8ca3 commit bdf3b8f

File tree

2 files changed

+26
-35
lines changed

2 files changed

+26
-35
lines changed
Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,33 @@
11
<?php namespace Syntax\SteamApi\Containers\Player;
22

3-
class Level {
4-
public $playerXp;
3+
class Level
4+
{
55

6-
public $playerLevel;
6+
public $playerXp;
77

8-
public $xpToLevelUp;
8+
public $playerLevel;
99

10-
public $xpForCurrentLevel;
10+
public $xpToLevelUp;
1111

12-
public $currentLevelFloor;
12+
public $xpForCurrentLevel;
1313

14-
public $currentLevelCeiling;
14+
public $currentLevelFloor;
1515

16-
public $percentThroughLevel;
16+
public $currentLevelCeiling;
1717

18-
public function __construct($levelDetails)
19-
{
20-
$this->playerXp = $levelDetails->player_xp;
21-
$this->playerLevel = $levelDetails->player_level;
22-
$this->xpToLevelUp = $levelDetails->player_xp_needed_to_level_up;
23-
$this->xpForCurrentLevel = $levelDetails->player_xp_needed_current_level;
18+
public $percentThroughLevel;
2419

25-
$this->currentLevelFloor = $this->xpForCurrentLevel;
26-
$this->currentLevelCeiling = $this->playerXp + $this->xpToLevelUp;
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;
2726

28-
$levelRange = $this->currentLevelCeiling - $this->currentLevelFloor;
29-
30-
$this->percentThroughLevel = $this->percent($this->xpToLevelUp, $levelRange);
31-
}
32-
33-
private function percent ($num_amount, $num_total)
34-
{
35-
if($num_amount == 0 || $num_total == 0){
36-
return 0;
37-
}
38-
else {
39-
$count1 = $num_amount / $num_total;
40-
$count2 = $count1 * 100;
41-
$count = number_format($count2, 0);
42-
return $count;
43-
}
44-
}
27+
$this->currentLevelFloor = $this->xpForCurrentLevel;
28+
$this->currentLevelCeiling = $this->playerXp + $this->xpToLevelUp;
4529

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+
}
4633
}

tests/NewsTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function it_gets_news_by_app_id()
1818
];
1919
$this->assertObjectHasAttributes($attributes, $newsArticle->newsitems[0]);
2020

21-
$this->assertEquals(23, strlen(strip_tags($newsArticle->newsitems[0]->contents)));
21+
$this->assertTrue(strlen(strip_tags($newsArticle->newsitems[0]->contents)) <= 23);
2222
}
2323

2424
/** @test */
@@ -40,7 +40,11 @@ public function it_gets_more_than_1_news_article_by_app_id()
4040
*/
4141
public function it_has_full_news_article_by_app_id($defaultNewsCall)
4242
{
43-
$this->assertGreaterThan(23, strlen(strip_tags($defaultNewsCall->newsitems[0]->contents)));
43+
foreach ($defaultNewsCall->newsitems as $newsItem) {
44+
if (strlen(strip_tags($newsItem->contents)) > 0) {
45+
$this->assertGreaterThan(23, strlen(strip_tags($newsItem->contents)));
46+
}
47+
}
4448
}
4549

4650
}

0 commit comments

Comments
 (0)