lithium\tests\integration\test\FilterTest::_powerSet PHP Method

_powerSet() protected method

protected _powerSet ( $in, $minLength = 1 )
    protected function _powerSet($in, $minLength = 1)
    {
        $count = count($in);
        $members = pow(2, $count);
        $return = array();
        for ($i = 0; $i < $members; $i++) {
            $b = sprintf("%0{$count}b", $i);
            $out = array();
            for ($j = 0; $j < $count; $j++) {
                if ($b[$j] === '1') {
                    $out[] = $in[$j];
                }
            }
            if (count($out) >= $minLength) {
                $return[] = $out;
            }
        }
        return $return;
    }