Creates a new Flow instance

@param string $environment
@param array $credentials
@param LoggerInterface|null $logger
@return Flow
@throws \Exception
184793
public static function make(string $environment, array $credentials, LoggerInterface $logger = null)
    {
        // If no logger is passed, we will use the null logger
        $flow = new static($logger ?? new NullLogger());

        // Set the credentials, or throw an Exception if there is none
        $flow->setCredentials($credentials);

        // Set the production environment if set explicitly
        $flow->isProduction($environment === 'production');

        // Set the default Guzzle Adapter
        $flow->setAdapter(new GuzzleAdapter($flow));

        // Return a new instance of Flow
        return $flow;
    }
516464
public function createSessionAsync(array $args)
    {
        $database = $this->pluck('database', $args);
        $opts = $this->addResourcePrefixHeader([], $database);
        $opts['credentialsWrapper'] = $this->credentialsWrapper;
        $transport = $this->spannerClient->getTransport();

        $request = new CreateSessionRequest([
            'database' => $database
        ]);

        $session = $this->pluck('session', $args, false);

        if ($session) {
            $sessionMessage = new Session($session);
            $request->setSession($sessionMessage);
        }

        return $transport->startUnaryCall(
            new Call(
                'google.spanner.v1.Spanner/CreateSession',
                Session::class,
                $request
            ),
            $opts
        );
    }
805980
public function create($name, CredentialsInterface $credentials, StorageInterface $storage, $scopes = [], $baseApiUri = null, $apiVersion = null)
    {
      $name = ucfirst($name);

      if(is_null($this->client))
        $this->client = new CurlClient();

      $class = '\\LibX\OAuth2\\Service\\' . $name;

      if(!class_exists($class))
        throw new \Exception('Service with name ' . $name . ' not found');

      return new $class($credentials, $this->client, $storage, $scopes, $baseApiUri);
    }
435322
public static function createFrom(
        Storage $persistenceProvider,
        Storage $cacheProvider,
        LoggerInterface $logger = null
    ) {
        /** @var $userAgentHandlerChain \Wurfl\Handlers\Chain\UserAgentHandlerChain */
        $userAgentHandlerChain = $cacheProvider->load('UserAgentHandlerChain');

        if (!($userAgentHandlerChain instanceof UserAgentHandlerChain)) {
            $userAgentHandlerChain = self::init();
            $cacheProvider->save('UserAgentHandlerChain', $userAgentHandlerChain, 3600);
        }

        $userAgentHandlerChain->setLogger($logger);

        foreach ($userAgentHandlerChain->getHandlers() as $handler) {
            /* @var $handler \Wurfl\Handlers\AbstractHandler */
            $handler
                ->setLogger($logger)
                ->setPersistenceProvider($persistenceProvider);
        }

        return $userAgentHandlerChain;
    }
963175
public function tokenize(array $credentials)
    {
        if (empty($credentials)) {
            throw new AuthenticationException('Unable to create token, no or empty credentials');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsCredentials($credentials)) {
                continue;
            }

            if (!$token = $provider->tokenize($credentials)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Unable to create token, credentials could not be authenticated in provider "%s"', get_class($provider)));
            }

            $this->stash()
                 ->put($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Unable to create token, missing provider supporting credentials "%s"', implode(', ', array_keys($credentials))));
    }
1181718
public function create($credentialsProfileName = 'default')
    {
        if (!isset($this->credentialProfiles[$credentialsProfileName])) {
            throw new Exception(sprintf('The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.', $credentialsProfileName), 1446553024);
        }

        if (!empty($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded'])) {
            $googleCloud = new ServiceBuilder([
                'keyFile' => json_decode(base64_decode($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded']), true)
            ]);
        } else {
            if (substr($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'], 0, 1) !== '/') {
                $privateKeyPathAndFilename = FLOW_PATH_ROOT . $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'];
            } else {
                $privateKeyPathAndFilename = $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'];
            }

            if (!file_exists($privateKeyPathAndFilename)) {
                throw new Exception(sprintf('The Google Cloud Storage private key file "%s" does not exist. Either the file is missing or you need to adjust your settings.', $privateKeyPathAndFilename), 1446553054);
            }
            $googleCloud = new ServiceBuilder([
                'keyFilePath' => $privateKeyPathAndFilename
            ]);
        }

        return $googleCloud->storage();
    }
123543
protected function newLogEntry(
        /*# string */ $channel,
        /*# string */ $level,
        /*# string */ $message,
        array $context = []
    )/*# : EventInterface */ {
        if (is_null($this->entry_proto)) {
            return new LogEntry($channel, $level, $message, $context);
        } else {
            $entry = clone $this->entry_proto;
            return $entry
                ->setChannel($channel)
                ->setLevel($level)
                ->setMessage($message)
                ->setContext($context)
                ->setTimestamp();
        }
    }
1176450
private function createFluentHandler(array $config): HandlerInterface
    {
        $configure = $this->app['config']['fluent'];
        $fluentHandler = $this->detectHandler($configure);
        return new $fluentHandler(
            new FluentLogger(
                $configure['host'] ?? FluentLogger::DEFAULT_ADDRESS,
                (int)$configure['port'] ?? FluentLogger::DEFAULT_LISTEN_PORT,
                $configure['options'] ?? [],
                $this->detectPacker($configure)
            ),
            $configure['tagFormat'] ?? null,
            $this->level($config)
        );
    }
670655
public static function createFromEnvironment($env = [])
    {
        if (!($env instanceof Environment)) {
            $env = new Environment($env);
        }

        // Headers from environment
        $data = [];
        foreach($env as $k=>$v) {
            $k = strtoupper($k);
            if (strpos($k, 'HTTP_') === 0) {
                $k = substr($k, 5);
            } else {
                if (!isset(static::$special[$k]))
                    continue;
            }

            // normalize key
            $k = str_replace(
                ' ',
                '-',
                ucwords(strtolower(str_replace('_', ' ', $k)))
            );

            $data[$k] = $v;
        }

        return new static($data);
    }
1305986
public function createRecord(
        $loggerNamespace,
        $loggerClass,
        $loggerMethod,
        $namespace,
        $class,
        $method,
        $level,
        $filename,
        $lineno,
        $msg,
        array $args,
        \Exception $exception = null
    ) {
        $record = new \Plop\Record(
            $loggerNamespace,
            $loggerClass,
            $loggerMethod,
            $namespace,
            $class,
            $method,
            $level,
            $filename,
            $lineno,
            $msg,
            $args,
            $this->interpolator,
            $exception
        );
        return $record;
    }
218177
public function createCredentials()
    {
        $credentials = new Credentials();
        $credentials->setTransactor($this);
        $credentials->setCredentials(array(
            'providerId' => null,
            'providerGateId' => null,
            'providerGateKey' => null,
            'merchantId' => null,
            'merchantGateId' => null,
            'merchantGateKey' => null
        ));

        return $credentials;
    }
550783
public function setAuthentication(array $credentials): AbstractClientBuilder
    {
        if (array_key_exists('session_id', $credentials)) {
            $this->authentication = new HeaderAuthenticate($credentials['session_id']);
        } elseif (array_key_exists('username', $credentials) && array_key_exists('password', $credentials)) {
            $this->authentication = new HeaderLogin($credentials['username'], $credentials['password']);
        } else {
            throw new \InvalidArgumentException('No credentials given.');
        }

        return $this;
    }
359307
public function ciRun($environment, $args = '')
    {
        $runner = new Runner($environment);
        $runner->buildImage();
        $runner->runServices();
        $res = $runner->getContainerRunner()
            ->exec($runner->getRunCommand())
            ->args($args)
            ->run();

        $runner->stopServices();

        !$res->getExitCode()
            ? $this->yell('BUILD SUCCESSFUL')
            : $this->say("<error> BUILD FAILED </error>");

        $data = $res->getData();
        $this->say("To enter this container, save it with <info>docker commit {$data['cid']} travis_build_failed<info>");
        $this->say('Then you can run it: <info>docker run -i -t travis_build_failed bash</info>');
    }
463474
private function buildClient(
        RequestFactoryInterface $factory,
        SenderInterface $sender,
        LoggerInterface $logger,
        $service
    ) {
        return $service !== null
            ? new ServiceClient($factory, $sender, $logger, $service)
            : new MultiClient($factory, $sender, $logger);
    }
508300
private function setCasEnvironment($environment)
    {
        switch ($environment) {
            case 'development':
                $this->setCasHost('authtest.it.usf.edu');
                $this->setCasPort(443);
                $this->setCasContext('/');
                $this->configureCasClient();
                $this->setCasCaCertPath('/etc/USF-CA-chain.pem');
                phpCAS::handleLogoutRequests(false);
                break;

            case 'production':
                $this->setCasHost('webauth.usf.edu');
                $this->setCasPort(443);
                $this->setCasContext('/');
                $this->configureCasClient();
                $this->setCasCaCertPath('/etc/USF-CA-chain.pem');
                phpCAS::handleLogoutRequests(false);
                break;

            case 'impersonate':
                $this->setCasHost('authtest.it.usf.edu');
                $this->setCasPort(444);
                $this->setCasContext('/');
                $this->configureCasClient();
                $this->setCasCaCertPath('/etc/USF-CA-chain.pem');
                phpCAS::handleLogoutRequests(false);
                break;

            default:
                throw new Exception("Unknown auth environment: " . $environment, 500);
                break;
        }
    }
1317488
public function process(Environment $env, $em, Logger $logger)
    {
        $path = str_replace($this->repositoryPath, '', $this->controllerPath);
        $name = str_replace('/', $this->controllerClass, $path);
        $controller = str_replace('.php', '', $name);

        if (!class_exists($controller)) {
            throw new Bomb('can not load class "' . $controller . '" from the repository');
        }

        return new $controller(
            $this->request, new Response($this->request->getMethod()), $logger, $em, $this->router, $env
        );
    }
202287
public function connect($credentials = [])
    {
        if ($diff = array_diff(array_keys($this->settings), array_keys($credentials))) {
            throw new \Exception("Missing credentials, the following fields are missing ".implode('/', $diff));
        }

        $this->settings = array_merge($this->settings, $credentials);

        if (isset($this->settings['port']) === false) {
            $this->settings['port'] = 143;
        }

        $this->conn = @imap_open('{'.$this->settings['server'].':'.$this->settings['port'].'/notls}',
            $this->settings['username'], $this->settings['password']);

        if ($this->conn == false) {
            throw new \Exception("Could not connect or authorize to ".$this->settings['server'].':'.$this->settings['port']);
        }

        return ($this->conn != null);
    }