Passed
Push — master ( 08b4be...8d11b6 )
by IRFA
01:57 queued 10s
created

Roll::jsonSpin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php 
2
/* 
3
	Author:Irfa Ardiansyah <[email protected]>
4
	Simple Items Gatcha with PHP
5
*/
6
namespace Irfa\Gatcha;
7
8
use Irfa\Gatcha\Roulette\Roulette;
9
use Exception;
10
11
class Roll extends Roulette {
12
13
	private static $items;
14
15
	public static function put($items)
16
	{
17
		self::$items = $items;
18
19
		return new static();
20
	}
21
	public static function spin() 
22
	{
23
		return self::getItem();
24
	}
25
	public static function jsonSpin() 
26
	{
27
		$ret = self::getItem();
28
		return self::jsonItem($ret);
29
	}
30
	public static function dropUp($items, $rate)
31
	{
32
		$items_bucket = self::$items;
33
		self::putDropUp(self::itemDropUp($items_bucket, $items, $rate));
34
		return new static();
35
	}
36
	private static function getItem() {
37
		$ret = self::get(self::$items);
38
		self::$items = null;
39
		return $ret;
40
	}
41
	private static function putDropUp($arr) {
42
		foreach ($arr as $k => $v) {
43
			self::$items[$k] = $v;
44
		}
45
	}
46
	
47
}