for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace loophp\collection\Operation;
use Closure;
use loophp\collection\Contract\Operation;
/**
* Class RSample.
*/
final class RSample implements Operation
{
* @var float
private $probability;
* RSample constructor.
*
* @param float $probability
public function __construct(float $probability)
$this->probability = $probability;
}
* {@inheritdoc}
public function on(iterable $collection): Closure
$probability = $this->probability;
$callback = static function ($item) use ($probability): bool {
$item
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$callback = static function (/** @scrutinizer ignore-unused */ $item) use ($probability): bool {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return (mt_rand() / mt_getrandmax()) < $probability;
};
return (new Filter($callback))->on($collection);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.