Skip to content

Commit 59928ed

Browse files
committed
Add Documentation
1 parent c4a2349 commit 59928ed

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

example.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<!DOCTYPE html>
88
<html>
99
<head>
10-
<title>Gatcha</title>
10+
<title>Basic Usage Example</title>
11+
<meta name="viewport" content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'>
1112
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css">
1213
</head>
1314
<body>
@@ -39,9 +40,10 @@
3940
'item 21' => 8.3,
4041

4142
])->spin()."</h2>" ?>
42-
</h2><h2>
43+
</h2>
4344
</div>
4445
</div>
4546
</div>
4647
</div>
4748
</body>
49+
</html>

src/Roll.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/*
33
Author:Irfa Ardiansyah <irfa.backend@protonmail.com>
44
Simple Items Gatcha with PHP
5+
v2.1
6+
https://github.com/irfaardy/php-gacha
57
*/
68
namespace Irfa\Gatcha;
79

@@ -12,32 +14,68 @@ class Roll extends Roulette {
1214

1315
private static $items;
1416

17+
/**
18+
* Put items to $items.
19+
*/
1520
public static function put($items)
1621
{
1722
self::$items = $items;
1823

1924
return new static();
2025
}
26+
27+
/**
28+
* Spin Roullete.
29+
*
30+
* @return string
31+
*/
2132
public static function spin()
2233
{
2334
return self::getItem();
2435
}
36+
37+
/**
38+
* Spin Roullete json result.
39+
*
40+
* @return json
41+
*/
2542
public static function jsonSpin()
2643
{
2744
$ret = self::getItem();
2845
return self::jsonItem($ret);
2946
}
47+
48+
/**
49+
* Add dropup rate.
50+
*
51+
* @param string $item
52+
* @param float $rate
53+
* @return mixed
54+
*/
3055
public static function dropUp($items, $rate)
3156
{
3257
$items_bucket = self::$items;
3358
self::putDropUp(self::itemDropUp($items_bucket, $items, $rate));
3459
return new static();
3560
}
61+
62+
/**
63+
* Get Spinned items.
64+
*
65+
* @return string
66+
*/
3667
private static function getItem() {
3768
$ret = self::get(self::$items);
3869
self::$items = null;
3970
return $ret;
4071
}
72+
73+
/**
74+
* put dropup item to $items variable.
75+
*
76+
* @param array $arr
77+
* @return void
78+
*/
4179
private static function putDropUp($arr) {
4280
foreach ($arr as $k => $v) {
4381
self::$items[$k] = $v;

src/Roulette/RateUp.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,37 @@
22
/*
33
Author:Irfa Ardiansyah <irfa.backend@protonmail.com>
44
Simple Items Gatcha with PHP
5+
v2.1
6+
https://github.com/irfaardy/php-gacha
57
*/
68
namespace Irfa\Gatcha\Roulette;
79

810
use Exception;
911

1012
class RateUp {
1113

14+
/**
15+
* Add drop up rate to items.
16+
*
17+
* @param mixed $item_list
18+
* @param array $items
19+
* @param float $rate
20+
* @return array
21+
*/
1222
protected static function _itemDropUp($item_list, $items, $rate)
1323
{
1424
$rt = new RateUp();
1525
return $rt->calc_rate($item_list, $items, $rate);
1626
}
27+
28+
/**
29+
* Calculate Drop Up Rate.
30+
*
31+
* @param mixed $item_list
32+
* @param array $items
33+
* @param float $rate
34+
* @return array
35+
*/
1736
private function calc_rate($item_list, $items, $rate)
1837
{
1938
$item = [];

src/Roulette/Roulette.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,46 @@
22
/*
33
Author:Irfa Ardiansyah <irfa.backend@protonmail.com>
44
Simple Items Gatcha with PHP
5+
v2.1
6+
https://github.com/irfaardy/php-gacha
57
*/
68
namespace Irfa\Gatcha\Roulette;
79

810
use Exception;
911
use Irfa\Gatcha\Roulette\RateUp;
1012

1113
class Roulette extends RateUp {
12-
14+
15+
/**
16+
* encode to Json.
17+
*
18+
* @param string $dt
19+
* @return json
20+
*/
1321
protected static function jsonItem($dt) {
1422
$data['data'] = ['item' => $dt];
1523
return json_encode($data);
1624
}
25+
26+
/**
27+
* Add drop up rate to items.
28+
*
29+
* @param mixed $item_list
30+
* @param array $items
31+
* @param float $rate
32+
* @return array
33+
*/
1734
protected static function itemDropUp($item_list, $items, $rate)
1835
{
1936
return self::_itemDropUp($item_list, $items, $rate);
2037
}
38+
39+
/**
40+
* Get Item.
41+
*
42+
* @param array $item
43+
* @return string
44+
*/
2145
protected static function get($items) {
2246
if (is_array($items))
2347
{

0 commit comments

Comments
 (0)