Roll::put()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php 
2
/* 
3
	Author:Irfa Ardiansyah <[email protected]>
4
	Simple Items Gatcha with PHP
5
	v2.1
6
	https://github.com/irfaardy/php-gacha
7
*/
8
namespace Irfa\Gatcha;
9
10
use Irfa\Gatcha\Roulette\Roulette;
11
use Exception;
12
13
class Roll extends Roulette {
14
15
	private static $items;
16
17
	 /**
18
     * Put items to $items.
19
     */
20
	public static function put($items)
21
	{
22
		self::$items = $items;
23
24
		return new static();
25
	}
26
	 
27
	 /**
28
     * Spin Roullete.
29
     *
30
     * @return string
31
     */
32
	public static function spin() 
33
	{
34
		return self::getItem();
35
	}
36
37
	/**
38
     * Spin Roullete json result.
39
     *
40
     * @return json
0 ignored issues
show
Bug introduced by
The type Irfa\Gatcha\json was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
     */
42
	public static function jsonSpin() 
43
	{
44
		$ret = self::getItem();
45
		return self::jsonItem($ret);
46
	}
47
48
	/**
49
     * Add dropup rate.
50
     *
51
     * @param string $item
52
     * @param float $rate
53
     * @return mixed
54
     */
55
	public static function dropUp($items, $rate)
56
	{
57
		$items_bucket = self::$items;
58
		self::putDropUp(self::itemDropUp($items_bucket, $items, $rate));
59
		return new static();
60
	}
61
62
	/**
63
     * Get Spinned items.
64
     *
65
     * @return string
66
     */
67
	private static function getItem() {
68
		$ret = self::get(self::$items);
69
		self::$items = null;
70
		return $ret;
71
	}
72
73
	/**
74
     * put dropup item to $items variable.
75
     *
76
     * @param array $arr
77
     * @return void
78
     */
79
	private static function putDropUp($arr) {
80
		foreach ($arr as $k => $v) {
81
			self::$items[$k] = $v;
82
		}
83
	}
84
	
85
}