Finds the gateway based on the carrier and MMS.

@param string $carrier
@param bool   $mms

@return string
183102
protected function lookupGateway($carrier, $mms)
    {
        if ($mms) {
            switch ($carrier) {
                case 'att':
                    return 'mms.att.net';

                case 'airfiremobile':
                    throw new \InvalidArgumentException('Air Fire Mobile does not support Email Gateway MMS messages.');
                case 'alaskacommunicates':
                    return 'msg.acsalaska.com';

                case 'ameritech':
                    throw new \InvalidArgumentException('Ameritech does not support Email Gateway MMS messages.');
                case 'assurancewireless':
                    return 'vmobl.com';

                case 'boostmobile':
                    return 'myboostmobile.com';

                case 'cleartalk':
                    throw new \InvalidArgumentException('Clear Talk does not support Email Gateway MMS messages.');
                case 'cricket':
                    return 'mms.mycricket.com ';

                case 'metropcs':
                    return 'mymetropcs.com';

                case 'nextech':
                    throw new \InvalidArgumentException('NexTech does not support Email Gateway MMS messages.');
                case 'projectfi':
                    return 'msg.fi.google.com';

                case 'rogerswireless':
                    return 'mms.rogers.com';

                case 'unicel':
                    return 'utext.com';

                case 'verizonwireless':
                    return 'vzwpix.com';

                case 'virginmobile':
                    return 'vmpix.com';

                case 'tmobile':
                    return 'tmomail.net';

                case 'sprint':
                    return 'pm.sprint.com';

                case 'uscellular':
                    return 'mms.uscc.net';

                default:
                    throw new \InvalidArgumentException('Carrier specified is not found.');
            }
        } else {
            switch ($carrier) {
                case 'att':
                    return 'txt.att.net';

                case 'airfiremobile':
                    return 'sms.airfiremobile.com';

                case 'alaskacommunicates':
                    return 'msg.acsalaska.com';

                case 'ameritech':
                    return 'paging.acswireless.com';

                case 'assurancewireless':
                    return 'vmobl.com';

                case 'boostmobile':
                    return 'sms.myboostmobile.com';

                case 'cleartalk':
                    return 'sms.cleartalk.us';

                case 'cricket':
                    return 'sms.mycricket.com';

                case 'metropcs':
                    return 'mymetropcs.com';

                case 'nextech':
                    return 'sms.ntwls.net';

                case 'projectfi':
                    return 'msg.fi.google.com';

                case 'rogerswireless':
                    return 'sms.rogers.com';

                case 'unicel':
                    return 'utext.com';

                case 'verizonwireless':
                    return 'vtext.com';

                case 'virginmobile':
                    return 'vmobl.com';

                case 'tmobile':
                    return 'tmomail.net';

                case 'sprint':
                    return 'messaging.sprintpcs.com';

                case 'uscellular':
                    return 'email.uscc.net';

                default:
                    throw new \InvalidArgumentException('Carrier specified is not found.');
            }
        }
    }
704114
public function routeNotificationFor($driver)
    {
        if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
            return $this->{$method}();
        }

        switch ($driver) {
            case 'database':
                return $this->notifications();
            case 'mail':
                return $this->email;
            case 'nexmo':
                return $this->phone_number;
        }
    }
756229
protected function basic_get_ok($reader, $message)
    {
        $delivery_tag = $reader->read_longlong();
        $redelivered = $reader->read_bit();
        $exchange = $reader->read_shortstr();
        $routing_key = $reader->read_shortstr();
        $message_count = $reader->read_long();

        $message->delivery_info = array(
            'delivery_tag' => $delivery_tag,
            'redelivered' => $redelivered,
            'exchange' => $exchange,
            'routing_key' => $routing_key,
            'message_count' => $message_count
        );

        return $message;
    }
680492
public function findLinks($serviceName, $tcpPorts = [], $udpPorts = [])
    {
        // First match names
        $matching = [];
        $encodedName = $this->encodeServiceName($serviceName);

        $regex = '/^' . $encodedName . '_([0-9]+)$/';

        if (!is_array($this->links)) {
            return [];
        }

        foreach ($this->links as $link) {
            if (preg_match($regex, $link->getName())) {
                $matching[] = $link;
            }
        }

        // Find those that match TCP ports
        $matching = array_filter(
            $matching,
            function (ContainerLink $link) use ($tcpPorts) {
                foreach ($tcpPorts as $tcpPort) {
                    if (!$link->hasEndpoint($tcpPort, 'tcp')) {
                        return false;
                    }
                }

                return true;
            }
        );

        // Reduce even more by finding those that match UDP ports
        $matching = array_filter(
            $matching,
            function (ContainerLink $link) use ($udpPorts) {
                foreach ($udpPorts as $udpPort) {
                    if (!$link->hasEndpoint($udpPort, 'udp')) {
                        return false;
                    }
                }

                return true;
            }
        );

        return $matching;
    }
1342021
public function driver($driver)
    {
        $this->container['sms.sender'] = $this->container->share(function ($app) use ($driver) {
            return (new DriverManager($app))->driver($driver);
        });

        $this->driver = $this->container['sms.sender'];
    }
248996
public function getMobileTraffic($parameters = [], $parseResult = true)
    {
        $this->setParams([
            'metrics'    => 'ga:sessions,ga:pageviews,ga:sessionDuration',
            'dimensions' => 'ga:mobileDeviceInfo,ga:source',
            'segment'    => 'gaid::-14',
        ]);

        return $this->execute($parameters, $parseResult);
    }
601282
public function getUrlPort($proto)
    {
        $port = '';
        
        if (!empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
            $port = $_SERVER['HTTP_X_FORWARDED_PORT'];
        } elseif (!empty($_SERVER['SERVER_PORT'])) {
            $port = $_SERVER['SERVER_PORT'];
        } elseif ($proto === 'https') {
            $port = 443;
        } else {
            $port = 80;
        }
        
        return $port;
    }
336765
public function extract($format, $carrier){
        $spanContext = new SpanContext(0, 0, 0, null, 0);
        foreach ($carrier as $k => $v){
            $k = strtolower($k);
            $v = urldecode($v);
            if($k == Constants\Tracer_State_Header_Name){
                list($traceId, $spanId, $parentId,$flags) = explode(':', $carrier[strtoupper($k)]);

                $spanContext->spanId = $spanContext->hexToSignedInt($spanId);
                $spanContext->parentId = $spanContext->hexToSignedInt($parentId);
                $spanContext->flags = $flags;
                $spanContext->traceIdToString($traceId);

            }elseif(stripos($k, Constants\Trace_Baggage_Header_Prefix) !== false){
                $safeKey = str_replace(Constants\Trace_Baggage_Header_Prefix, "", $k);
                $spanContext->withBaggageItem($safeKey, $v);
            }elseif($k == Constants\Jaeger_Debug_Header){
                $spanContext->debugId = $v;
            }elseif($k == Constants\Jaeger_Baggage_Header){
                // Converts a comma separated key value pair list into a map
                // e.g. key1=value1, key2=value2, key3 = value3
                // is converted to array { "key1" : "value1",
                //                                     "key2" : "value2",
                //                                     "key3" : "value3" }
                $parseVal = explode(',', $v);
                foreach ($parseVal as $val){
                    $kv = explode('=', trim($val));
                    if(count($kv)){
                        $spanContext->withBaggageItem($kv[0], $kv[1]);
                    }
                }
            }
        }


        return $spanContext;
    }
183753
protected function getGateway()
    {
        /* @var $module \gplcart\modules\omnipay_library\Main */
        $module = $this->module->getInstance('omnipay_library');

        /** @var \Omnipay\AuthorizeNet\SIMGateway $gateway */
        $gateway = $module->getGatewayInstance('AuthorizeNet_SIM');

        if (!$gateway instanceof SIMGateway) {
            throw new UnexpectedValueException('Gateway must be instance of Omnipay\AuthorizeNet\SIMGateway');
        }

        return $gateway;
    }
758163
private function getGatewayForCertificate(Certificate $certificate)
	{
		// Get the fingerprint of the certificate
		$fingerprint = $certificate->getFingerprint();

		// If no gateway is available for this certificate create one
		if ( !isset($this->gatewayPool[$fingerprint]) )
		{
			$this->gatewayPool[$fingerprint] = $this->getGatewayFactory()->createGateway($certificate);
			$this->gatewayPool[$fingerprint]->setLogger($this->logger);
		}

		// Return the gateway connection for this certificate
		return $this->gatewayPool[$fingerprint];
	}
1078839
public function fix($mobileOrCarrier) {
    // If instance of carrier
    if ($mobileOrCarrier instanceof Carrier) {
      // Use
      $this->carrier = $mobileOrCarrier;
    }
    // If instance of mobile
    elseif ($mobileOrCarrier instanceof Mobile) {
      // Get carrier
      $this->carrier = $mobileOrCarrier->carrier;
    }
    // Else 
    else {
      // Get carrier
      $this->carrier =  Loader::mobile($mobileOrCarrier)->carrier;
    }
    // Adjust and return
    return $this->adjust();
  }
809404
public function queue(Message $message)
	{
		// Get the gateway for the certificate
		$gateway = $this->getGatewayForCertificate( $message->getCertificate() );

		// Queue the message
		return $gateway->queue($message);
	}
312369
private function readMccMncAndMobileCarrierName($pointer) {
    if (false === $pointer) {
      // Deal with invalid IPs
      $mcc               = self::INVALID_IP_ADDRESS;
      $mnc               = self::INVALID_IP_ADDRESS;
      $mobileCarrierName = self::INVALID_IP_ADDRESS;
    } elseif (0 === self::$columns[self::MCC][$this->type]) {
      // If the field is not suported, return accordingly
      $mcc               = self::FIELD_NOT_SUPPORTED;
      $mnc               = self::FIELD_NOT_SUPPORTED;
      $mobileCarrierName = self::FIELD_NOT_SUPPORTED;
    } else {
      // Read MCC, MNC, and mobile carrier name
      $mcc               = $this->readString($pointer + self::$columns[self::MCC][$this->type]);
      $mnc               = $this->readString($pointer + self::$columns[self::MNC][$this->type]);
      $mobileCarrierName = $this->readString($pointer + self::$columns[self::MOBILE_CARRIER_NAME][$this->type]);
    }
    return [$mcc, $mnc, $mobileCarrierName];
  }
832379
public function adjust(Carrier $carrier = null) {
    // If there's carrier
    if ($carrier !== null) {
      // Set carrier
      $this->carrier = $carrier;
    }
    // If there's no carrier
    if ( ! isset($this->carrier)) {
      // Throw error
      throw new MissingCarrier('Carrier is required to adjust cost');
    }
    // Get costs
    $costs = $this->getPossibleCostsPerCarrier()[$this->carrier->network];
    // Loop through costs per carrier
    foreach ($costs as $i=> $cost) {
      // If cost equals
      if ($this->amount == $cost) {
        // Quit
        break;
      }
      // If amount is less than cost
      if ($this->amount < $cost || ! isset($costs[$i + 1])) {
        // Use previous
        $this->amount = $cost;
        // Break
        break;
      }
    }
    // Return self
    return $this;
  }
383877
protected function findHost(array $headers): string
    {
        foreach ($headers as $name => $values) {
            if (strtolower($name) === 'host') {
                return $values[0];
            }
        }

        throw new MessageException(Response::BAD_REQUEST, 'No host header in message.');
    }
902060
public function findThirdPartyByProvider($provider)
    {
        foreach ($this->thirdPartyCredentials as $thirdParty) { /* @var ThirdParty $thirdParty */
            if ($thirdParty->getProvider() === $provider) {
                return $thirdParty;
            };
        }

        return;
    }
730644
public function checkTransport($from)
    {
        if (! array_key_exists($from, self::$mailServers)) {
            $sql = 'SELECT * FROM gems__mail_servers WHERE ? LIKE gms_from ORDER BY LENGTH(gms_from) DESC LIMIT 1';

            // Always set cache, se we know when not to check for this row.
            $serverData = $this->db->fetchRow($sql, $from);

            // \MUtil_Echo::track($serverData);

            if (isset($serverData['gms_server'])) {
                $options = array();
                if (isset($serverData['gms_user'], $serverData['gms_password'])) {
                    $options['auth'] = 'login';
                    $options['username'] = $serverData['gms_user'];
                    $options['password'] = $this->project->decrypt($serverData['gms_password']);
                }
                if (isset($serverData['gms_port'])) {
                    $options['port'] = $serverData['gms_port'];
                }
                if (isset($serverData['gms_ssl'])) {
                    switch ($serverData['gms_ssl']) {
                        case self::MAIL_SSL:
                            $options['ssl'] = 'ssl';
                            break;

                        case self::MAIL_TLS:
                            $options['ssl'] = 'tls';
                            break;

                        default:
                            // intentional fall through

                    }
                }

                self::$mailServers[$from] = new \Zend_Mail_Transport_Smtp($serverData['gms_server'], $options);
            } else {
                self::$mailServers[$from] = $this->getDefaultTransport();
            }
        }

        return self::$mailServers[$from];
    }