You are here

protected function FedEx::getCleanTitle in Commerce FedEx 8

Gets a cleaned title string for use in sending to FedEx.

Parameters

\Drupal\commerce_shipping\ShipmentItem $shipment_item: The shipment item.

Return value

string The cleaned title.

1 call to FedEx::getCleanTitle()
FedEx::getRequestedPackageLineItemsIndividual in src/Plugin/Commerce/ShippingMethod/FedEx.php
Gets package line items for PACKAGE_INDIVIDUAL strategy.

File

src/Plugin/Commerce/ShippingMethod/FedEx.php, line 671

Class

FedEx
Provides the FedEx shipping method.

Namespace

Drupal\commerce_fedex\Plugin\Commerce\ShippingMethod

Code

protected function getCleanTitle(ShipmentItem $shipment_item) {
  $title = $shipment_item
    ->getTitle();
  $title = preg_replace('/[^A-Za-z0-9 ]/', ' ', $title);
  $title = preg_replace('/ +/', ' ', $title);
  return trim($title);
}