Logidav Docs

ShipmentService
in package

Class ShipmentService

Provides services related to shipment handling.

Table of Contents

Properties

$container  : ContainerInterface
$entityManager  : EntityManagerInterface

Methods

__construct()  : mixed
ShipmentService constructor.
generateParcelsForProduct()  : array<string|int, mixed>
Generate parcels for a given product.
getPackagesInfos()  : array<string|int, mixed>
Retrieves the package information for a given product.
getTotalPackages()  : int
Returns the total number of packages for a given product.
isValidParcels()  : bool
Validates an array of parcels.

Properties

Methods

__construct()

ShipmentService constructor.

public __construct(ContainerInterface $container, EntityManagerInterface $entityManager) : mixed
Parameters
$container : ContainerInterface
$entityManager : EntityManagerInterface

generateParcelsForProduct()

Generate parcels for a given product.

public generateParcelsForProduct(Product $product) : array<string|int, mixed>
Parameters
$product : Product

The product for which to generate parcels.

Return values
array<string|int, mixed> —

Returns an array of parcels, each containing the following information:

  • width: The width of the parcel.
  • height: The height of the parcel.
  • length: The length of the parcel.
  • weight: The weight of the parcel.

getPackagesInfos()

Retrieves the package information for a given product.

public getPackagesInfos(Product $product) : array<string|int, mixed>
Parameters
$product : Product

The product object.

Return values
array<string|int, mixed> —

The array of package information for the product.

getTotalPackages()

Returns the total number of packages for a given product.

public getTotalPackages(Product $product) : int
Parameters
$product : Product

The product object for which to calculate the total number of packages.

Return values
int —

The total number of packages for the given product.

isValidParcels()

Validates an array of parcels.

public isValidParcels(array<string|int, mixed> $parcels, int $totalParcelNumber) : bool
Parameters
$parcels : array<string|int, mixed>

An array of parcels to be validated. Each parcel should have 'weight', 'height', 'length', and 'width' keys.

$totalParcelNumber : int

The expected total number of parcels.

Return values
bool —

Returns true if all parcels are valid and their count matches the expected total number, otherwise returns false.


        
On this page

Search results