Passed
Push — master ( a4d127...dc8535 )
by IRFA
03:20 queued 01:33
created

Roll::itemDropUp()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 9
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\Roulete\Roulete;
9
use Exception;
10
11
class Roll extends Roulete {
12
13
	private static $items;
14
	private static $return;
0 ignored issues
show
introduced by
The private property $return is not used, and could be removed.
Loading history...
15
16
	public static function put($items)
17
	{
18
		self::$items = $items;
19
20
		return new static();
21
	}
22
	public static function spin() 
23
	{
24
		return self::getItem();
25
	}
26
	public static function dropUp($items, $rate)
27
	{
28
		self::itemDropUp($items,$rate);
29
		return new static();
30
	}
31
	private static function getItem(){
32
		$ret =  self::get(self::$items);
0 ignored issues
show
Bug Best Practice introduced by
The method Irfa\Gatcha\Roulete\Roulete::get() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
		/** @scrutinizer ignore-call */ 
33
  $ret =  self::get(self::$items);
Loading history...
33
		self::$items=null;
34
		return $ret;
35
	}
36
	private static function itemDropUp($items,$rate){
37
		if(is_array($items))
38
		{
39
			foreach($items as $itm)
40
			{
41
				self::$items[$itm] = self::$items[$itm]*($rate/100);
42
			}
43
		} else {
44
				self::$items[$items] = self::$items[$items]*($rate/100);
45
		}
46
		
47
	}
48
}