public function getOneById(CartInterface $cart, $shippingMethodId)
    {
        $shippingMethods = $this->get($cart);

        return array_reduce(
            $shippingMethods,
            function (
                $foundShippingMethod,
                ShippingMethod $shippingMethod
            ) use ($shippingMethodId) {

                return ($shippingMethodId === $shippingMethod->getId())
                    ? $shippingMethod
                    : $foundShippingMethod;
            },
            null
        );
    }
public function getOneById(CartInterface $cart, $shippingMethodId)
    {
        $shippingMethods = $this->get($cart);

        return array_reduce(
            $shippingMethods,
            function (
                $foundShippingMethod,
                ShippingMethod $shippingMethod
            ) use ($shippingMethodId) {

                return ($shippingMethodId === $shippingMethod->getId())
                    ? $shippingMethod
                    : $foundShippingMethod;
            },
            null
        );
    }
public function getOneById ( CartInterface $ cart , $ shippingMethodId ) { $ shippingMethods = $ this -> get ( $ cart ) ; return array_reduce ( $ shippingMethods , function ( $ foundShippingMethod , ShippingMethod $ shippingMethod ) use ( $ shippingMethodId ) { return ( $ shippingMethodId === $ shippingMethod -> getId ( ) ) ? $ shippingMethod : $ foundShippingMethod ; } , null ) ; }
Get loaded shipping method given its id.

@param CartInterface $cart             Cart
@param string        $shippingMethodId Shipping method id

@return ShippingMethod|null Required shipping method
Get loaded shipping method given its id .