src/Controller/PickupController.php
protected function getMethod(?string $shippingMethod): ShippingMethod
    {
        /** @var ShippingMethod|null $method */
        $method = $this->getShippingMethodRepository()->findOneBy(['code' => $shippingMethod]);

        if ($method === null) {
            return false;
        }

        return $method;
    }
protected function getMethod(?string $shippingMethod): ShippingMethod
    {
        /** @var ShippingMethod|null $method */
        $method = $this->getShippingMethodRepository()->findOneBy(['code' => $shippingMethod]);

        if ($method === null) {
            return false;
        }

        return $method;
    }
Retrieve Shipping Method

@param string $shippingMethod
@return ShippingMethod|bool