vendor/shopware/core/Checkout/Shipping/Aggregate/ShippingMethodPrice/ShippingMethodPriceCollection.php line 16

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Checkout\Shipping\Aggregate\ShippingMethodPrice;
  3. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  4. /**
  5.  * @method void                           add(ShippingMethodPriceEntity $entity)
  6.  * @method void                           set(string $key, ShippingMethodPriceEntity $entity)
  7.  * @method ShippingMethodPriceEntity[]    getIterator()
  8.  * @method ShippingMethodPriceEntity[]    getElements()
  9.  * @method ShippingMethodPriceEntity|null get(string $key)
  10.  * @method ShippingMethodPriceEntity|null first()
  11.  * @method ShippingMethodPriceEntity|null last()
  12.  */
  13. class ShippingMethodPriceCollection extends EntityCollection
  14. {
  15.     public function getShippingMethodIds(): array
  16.     {
  17.         return $this->fmap(function (ShippingMethodPriceEntity $shippingMethodPrice) {
  18.             return $shippingMethodPrice->getShippingMethodId();
  19.         });
  20.     }
  21.     public function filterByShippingMethodId(string $id): self
  22.     {
  23.         return $this->filter(function (ShippingMethodPriceEntity $shippingMethodPrice) use ($id) {
  24.             return $shippingMethodPrice->getShippingMethodId() === $id;
  25.         });
  26.     }
  27.     public function getApiAlias(): string
  28.     {
  29.         return 'shipping_method_price_collection';
  30.     }
  31.     protected function getExpectedClass(): string
  32.     {
  33.         return ShippingMethodPriceEntity::class;
  34.     }
  35. }