public function getLowestPrice( array $priceItems, $quantity )
	{
		$priceList = array();

		foreach( $priceItems as $priceItem )
		{
			$iface = 'MShop_Price_Item_Interface';
			if( ( $priceItem instanceof $iface ) === false ) {
				throw new MShop_Price_Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
			}

			$priceList[ $priceItem->getQuantity() ] = $priceItem;
		}

		ksort( $priceList );

		if( ( $price = reset( $priceList ) ) === false ) {
			throw new MShop_Price_Exception( sprintf( 'Price item not available' ) );
		}

		if( $price->getQuantity() > $quantity )
		{
			$msg = sprintf( 'Price for the given quantity "%1$d" not available', $quantity );
			throw new MShop_Price_Exception( $msg );
		}

		foreach( $priceList as $qty => $priceItem )
		{
			if( $qty <= $quantity && $qty > $price->getQuantity() ) {
				$price = $priceItem;
			}
		}

		return clone $price;
	}
public function getLowestPrice( array $priceItems, $quantity )
	{
		$priceList = array();

		foreach( $priceItems as $priceItem )
		{
			$iface = 'MShop_Price_Item_Interface';
			if( ( $priceItem instanceof $iface ) === false ) {
				throw new MShop_Price_Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
			}

			$priceList[ $priceItem->getQuantity() ] = $priceItem;
		}

		ksort( $priceList );

		if( ( $price = reset( $priceList ) ) === false ) {
			throw new MShop_Price_Exception( sprintf( 'Price item not available' ) );
		}

		if( $price->getQuantity() > $quantity )
		{
			$msg = sprintf( 'Price for the given quantity "%1$d" not available', $quantity );
			throw new MShop_Price_Exception( $msg );
		}

		foreach( $priceList as $qty => $priceItem )
		{
			if( $qty <= $quantity && $qty > $price->getQuantity() ) {
				$price = $priceItem;
			}
		}

		return clone $price;
	}
public function getLowestPrice ( array $ priceItems , $ quantity ) { $ priceList = array ( ) ; foreach ( $ priceItems as $ priceItem ) { $ iface = 'MShop_Price_Item_Interface' ; if ( ( $ priceItem instanceof $ iface ) === false ) { throw new MShop_Price_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } $ priceList [ $ priceItem -> getQuantity ( ) ] = $ priceItem ; } ksort ( $ priceList ) ; if ( ( $ price = reset ( $ priceList ) ) === false ) { throw new MShop_Price_Exception ( sprintf ( 'Price item not available' ) ) ; } if ( $ price -> getQuantity ( ) > $ quantity ) { $ msg = sprintf ( 'Price for the given quantity "%1$d" not available' , $ quantity ) ; throw new MShop_Price_Exception ( $ msg ) ; } foreach ( $ priceList as $ qty => $ priceItem ) { if ( $ qty <= $ quantity && $ qty > $ price -> getQuantity ( ) ) { $ price = $ priceItem ; } } return clone $ price ; }
Returns the price item with the lowest price for the given quantity.

@param array $priceItems List of price items implementing MShop_Price_Item_Interface
@param integer $quantity Number of products
@throws MShop_Price_Exception if no price item is available
Returns the price item with the lowest price for the given quantity .