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\Roulette; |
||
9 | |||
10 | use Exception; |
||
11 | use Irfa\Gatcha\Roulette\RateUp; |
||
12 | |||
13 | class Roulette extends RateUp { |
||
14 | |||
15 | /** |
||
16 | * encode to Json. |
||
17 | * |
||
18 | * @param string $dt |
||
19 | * @return json |
||
0 ignored issues
–
show
|
|||
20 | */ |
||
21 | protected static function jsonItem($dt) { |
||
22 | $data['data'] = ['item' => $dt]; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
23 | return json_encode($data); |
||
0 ignored issues
–
show
|
|||
24 | } |
||
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 | */ |
||
34 | protected static function itemDropUp($item_list, $items, $rate) |
||
35 | { |
||
36 | return self::_itemDropUp($item_list, $items, $rate); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Get Item. |
||
41 | * |
||
42 | * @param array $item |
||
43 | * @return string |
||
44 | */ |
||
45 | protected static function get($items) { |
||
46 | if (is_array($items)) |
||
47 | { |
||
48 | $max = 0; |
||
49 | foreach ($items as $key => $value) { |
||
50 | $max += $value; |
||
51 | $items[$key] = $max; |
||
52 | } |
||
53 | |||
54 | $random = mt_rand(1, $max); |
||
55 | |||
56 | foreach ($items as $item => $max) |
||
57 | { |
||
58 | if ($random <= $max) { |
||
59 | break; |
||
60 | } |
||
61 | } |
||
62 | return $item; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
63 | } else { |
||
64 | throw new Exception('Parameter must be an array.'); |
||
65 | |||
66 | return false; |
||
0 ignored issues
–
show
return false is not reachable.
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed. Unreachable code is most often the result of function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last ![]() |
|||
67 | } |
||
68 | } |
||
69 | |||
70 | } |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths