for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
Author:Irfa Ardiansyah <[email protected]>
Simple Items Gatcha with PHP
*/
namespace Irfa\Gatcha\Roulette;
use Exception;
use Irfa\Gatcha\Roulette\RateUp;
class Roulette extends RateUp {
protected static function itemDropUp($item_list, $items, $rate)
{
return self::_itemDropUp($item_list, $items, $rate);
}
protected static function get($items) {
if (is_array($items))
$max = 0;
foreach ($items as $key => $value) {
$max += $value;
$items[$key] = $max;
$random = mt_rand(1, $max);
foreach ($items as $item => $max)
if ($random <= $max) {
break;
return $item;
$item
foreach
28
} else {
throw new Exception('Parameter must be an array.');
return false;
return false
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 return, die or exit statements that have been added for debug purposes.
return
die
exit
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.