private function getMaxInstallment($installments)
    {
        $final = $current = ['brand' => '', 'start' => 0, 'final' => 0, 'quantity' => 0];

        foreach ($installments as $key => $installment) {
            if ($current['brand'] !== $installment->getCardBrand()) {
                $current['brand'] = $installment->getCardBrand();
                $current['start'] = $key;
            }

            $current['quantity'] = $installment->getQuantity();
            $current['end'] = $key;

            if ($current['quantity'] > $final['quantity']) {
                $final = $current;
            }
        }
        
        return array_slice(
            $installments,
            $final['start'],
            $final['end'] - $final['start'] + 1
        );
    }
private function getMaxInstallment($installments)
    {
        $final = $current = ['brand' => '', 'start' => 0, 'final' => 0, 'quantity' => 0];

        foreach ($installments as $key => $installment) {
            if ($current['brand'] !== $installment->getCardBrand()) {
                $current['brand'] = $installment->getCardBrand();
                $current['start'] = $key;
            }

            $current['quantity'] = $installment->getQuantity();
            $current['end'] = $key;

            if ($current['quantity'] > $final['quantity']) {
                $final = $current;
            }
        }
        
        return array_slice(
            $installments,
            $final['start'],
            $final['end'] - $final['start'] + 1
        );
    }
private function getMaxInstallment ( $ installments ) { $ final = $ current = [ 'brand' => '' , 'start' => 0 , 'final' => 0 , 'quantity' => 0 ] ; foreach ( $ installments as $ key => $ installment ) { if ( $ current [ 'brand' ] !== $ installment -> getCardBrand ( ) ) { $ current [ 'brand' ] = $ installment -> getCardBrand ( ) ; $ current [ 'start' ] = $ key ; } $ current [ 'quantity' ] = $ installment -> getQuantity ( ) ; $ current [ 'end' ] = $ key ; if ( $ current [ 'quantity' ] > $ final [ 'quantity' ] ) { $ final = $ current ; } } return array_slice ( $ installments , $ final [ 'start' ] , $ final [ 'end' ] - $ final [ 'start' ] + 1 ) ; }
Get the bigger installments list in the installments
@param array $installments
@return array
Get the bigger installments list in the installments