Return a singleton instance of the class
@param GuzzleHttp\Client $transport
@return Arrowsphere\Client\xAC
341649
public static function getInstance(HttpClient $transport = null)
    {
        if (is_null(self::$client)) {
            self::$client = new self();
        
            if (! is_null($transport)) {
                self::$client->setTransport($transport);
            }
        }
        
        return self::$client;
    }
1216180
public static function createTransport($transport, array $config)
    {
        $config = new Structure($config);

        switch ($transport) {
            case 'smtp':
                $instance = \Swift_SmtpTransport::newInstance(
                    $config->get('smtp.host'),
                    $config->get('smtp.port', 2525),
                    $config->get('smtp.security', 'tls')
                )->setUsername($config->get('smtp.username'))
                    ->setPassword($config->get('smtp.password'));

                if ($config->get('smtp.local')) {
                    $instance->setLocalDomain($config->get('local'));
                }

                if (!$config->get('smtp.verify', true)) {
                    $instance->setStreamOptions(['ssl' => ['allow_self_signed' => true, 'verify_peer' => false]]);
                }

                break;

            case 'sendmail':
                $instance = \Swift_SendmailTransport::newInstance($config->get('sendmail'));

                break;

            default:
                $instance = \Swift_MailTransport::newInstance();
        }

        return $instance;
    }
1324450
public static function instance( Client $client = null, StorageInterface $storage = null ) {
        if ( is_null( self::$_instance ) ) {
            self::$_instance = new self( $client, $storage );
        }

        return self::$_instance;
    }
997827
public static function create($options = [], TransportInterface $transport = null)
    {
        $transport = $transport ?: static::getTransport();
        $options   = $options ?: static::getOptions();

        switch ($transport) {
            case 'mock':
                $mockOptions = isset($options['mock']) ? $options['mock'] : [];

                $transport = new StreamTransport($mockOptions);
                break;
            case 'stream':
                $streamOptions = isset($options['stream']) ? $options['stream'] : [];

                $transport = new StreamTransport($streamOptions);
                break;

            case 'curl':
            default:
                $curlOptions = isset($options['curl']) ? $options['curl'] : [];

                $transport = new CurlTransport($curlOptions);
                break;
        }

        return new HttpClient($options, $transport);
    }
883943
public static function createTransport(): TransportInterface
    {
        if (class_exists(HttpClientDiscovery::class) && class_exists(MessageFactoryDiscovery::class)) {
            try {
                return new HttpClientTransport(HttpClientDiscovery::find(), MessageFactoryDiscovery::find());
            } catch (NotFoundException $e) {
                // Do nothing
            }
        }

        if (class_exists(Client::class)) {
            return new Guzzle6Transport();
        }

        if (extension_loaded('curl')) {
            return new CurlExtensionTransport();
        }

        throw new RuntimeException('Cannot create an HTTP transport object');
    }
1000065
private function transport()
    {
        $this->transport = Transport::newInstance($this->smtp->get('host'), $this->smtp->get('port'), $this->smtp->get('encryption'))
            ->setUsername($this->smtp->get('username'))
            ->setPassword($this->smtp->get('password'));

        return $this->transport;
    }
362728
public function removeTransport(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport)
    {
        return $this->transports->removeElement($transport);
    }
472511
public function createClient($host, $port)
    {
        return $this->connector->create($host, $port)->then(function (DuplexStreamInterface $stream) {
            return new Client($stream);
        });
    }
1026002
public function onConnect(WebSocketTransportInterface $transport){
        /**
         * @var $stackTransport StackTransport
         * @var $jsonTransport RemoteEventTransport
         */
        $logger = $this->logger;
        $loop = $this->loop;
        $stackTransport = StackTransport::create($transport, array(function(TransportInterface $carrier) use($loop, $logger){
            return new RemoteEventTransport($carrier, $loop, $logger);
        }));

        $jsonTransport = $stackTransport->getTopTransport();

        $server = $transport->getHandshakeResponse()->getHeaders()->get('X-WebSocket-Server')->getFieldValue();

        $greetingMessage = RemoteEventMessage::create(null, "greeting", "hello world from $server!");

        $jsonTransport->whenResponseTo($greetingMessage, 0.1)->then(function(RemoteEventMessage $result) use ($logger, $server){
            $logger->notice(sprintf("Got '%s' in response to 'hello world from $server!'", $result->getData()));
        });

        $jsonTransport->remoteEvent()->on("greeting", function(RemoteEventMessage $message) use ($transport, $logger){
            $logger->notice(sprintf("We got a greeting event from {$transport->getId()}"));
        });
    }
420634
public static function singleton($classPath) {
        if ( !isset(self::$INSTANES[$classPath]) ) {
            $reflect = new \ReflectionClass($classPath);
            self::$INSTANES[$classPath] = $reflect->newInstance();
        }
        return self::$INSTANES[$classPath];
    }
1357790
public static function getInstance($options = [], TransportInterface $transport = null)
    {
        if (!static::$instance) {
            static::$instance = static::create($options, $transport);
        }

        return static::$instance;
    }
498117
public function send() {
        if (is_null($this->Transport)) {
            throw new TransportException();
        }
        $this->Transport->setRequest($this);
        return $this->Transport->makeHttpRequest($this);
    }
1078679
public static function getInstance($type, $init)
    {
        if (!self::$cachingInstance) {
            self::$cachingInstance = new MemcachedCache($type, $init);
        }

        return self::$cachingInstance;
    }
623031
public static function factory($host, $port, $sendTimeout = null, $receiveTimeout = null, $framedTransport = false)
    {
        $socket = self::createSocket($host, $port, $sendTimeout, $receiveTimeout);
        $transport = self::createTransport($socket, $framedTransport);
        $protocol = new TBinaryProtocolAccelerated($transport);
        $client = new RestClient($protocol);
        $transport->open();

        return $client;
    }
839154
public function deliver($swiftMessage, $transport = null)
    {
        // get the transport
        if (!$transport)
            $transport = $this->defaultTransport;
        if (!isset($this->transports[$transport]))
            throw new CException(Yii::t('email', 'Transport :transport is not configured.', array(':transport' => $transport)));

        // get transport options
        $options = $this->transports[$transport];

        // get transport class
        if (isset($options['class'])) {
            $class = $options['class'];
            unset($options['class']);
        } else {
            throw new CException(Yii::t('email', 'Transport :transport does not have a class.', array(':transport' => $transport)));
        }

        // get transport setters
        if (isset($options['setters'])) {
            $setters = $options['setters'];
            unset($options['setters']);
        } else {
            $setters = array();
        }

        // create a new transport using class, options and setters
        $swiftTransport = call_user_func_array($class . '::newInstance', $options);
        foreach ($setters as $k => $v) {
            call_user_func_array(array($swiftTransport, 'set' . ucfirst($k)), array($v));
        }

        // send the message using the transport
        return Swift_Mailer::newInstance($swiftTransport)->send($swiftMessage);
    }
211989
public function getInstance(): Router
    {
        if (! isset(self::$instance)) {
            self::$instance = new self();
        }
        
        return self::$instance;
    }
357660
public function getTransport($transportName)
    {
        if (empty($this->transport[$transportName])) {
            throw new InvalidArgumentException(sprintf('Transport %s not found', $transportName));
        }

        return $this->transport[$transportName];
    }