B0Bka / box

0 stars 0 forks source link

minprice #33

Open B0Bka opened 6 years ago

B0Bka commented 6 years ago

` public function setOffers(array $offers = []) { $this->offers = [ 'all' => [], 'minPrice' => false ]; if(!empty($offers)) { $offer = current($offers); $offer = array_reduce($offers, function(Offer $offer, Offer $o) { if(($o->getPrice() < $offer->getPrice())) { $offer = $o; } return $offer; }, $offer);

        $this->offers['all'] = $offers;
        $this->offers['minPrice'] = $offer;
    }
    return $this;
}`