/** * Creates a new InputEndpoint from parsed response body. * * @param array $parsed The parsed response body in array representation. * * @return InputEndpoint */ public static function create($parsed) { $inputEndpoint = new self(); $vip = Utilities::tryGetValue($parsed, Resources::XTAG_VIP); $port = Utilities::tryGetValue($parsed, Resources::XTAG_PORT); $roleName = Utilities::tryGetValue($parsed, Resources::XTAG_ROLE_NAME); $inputEndpoint->setPort($port); $inputEndpoint->setRoleName($roleName); $inputEndpoint->setVip($vip); return $inputEndpoint; }
/** * Factory method to hydrate an instance from serialized options * * @param array $options * @return self */ public static function fromArray(array $options) { $options = array_replace(['host' => '127.0.0.1', 'port' => 9200, 'index' => '', 'shards' => 3, 'replicas' => 0, 'minScore' => 4, 'highlight' => true], $options); $self = new self(); $self->setHost($options['host']); $self->setPort($options['port']); $self->setIndexName($options['index']); $self->setShards($options['shards']); $self->setReplicas($options['replicas']); $self->setMinScore($options['minScore']); $self->setHighlight($options['highlight']); return $self; }
/** * Returns Data Source Name String. * @access public * @static * @param string $driver Database Driver (cubrid|dblib|firebird|informix|mysql|mssql|oci|odbc|pgsql|sqlite|sybase) * @param string $database Database Name * @param string $host Host Name or URI * @param int $port Host Port * @param string $username Username * @param string $password Password * @return string */ public static function renderStatic($driver, $database, $host = NULL, $port = NULL, $username = NULL, $password = NULL) { $dsn = new self($driver, $database); $dsn->setHost($host); $dsn->setPort($port); $dsn->setUsername($username); $dsn->setPassword($password); return $dsn->render(); }
/** * Builds a new URI object from server environment * * @param array $environment Server environment (e.g. $_SERVER) * @return Uri */ public static function fromEnvironment(array $environment) { $uri = new self(); $uri->setScheme(isset($environment['HTTPS']) && ($environment['HTTPS'] == 'on' || $environment['HTTPS'] == 1) || isset($environment['HTTP_X_FORWARDED_PROTO']) && $environment['HTTP_X_FORWARDED_PROTO'] == 'https' ? 'https' : 'http'); $uri->setHostname($environment['HTTP_HOST']); $uri->setPort(isset($environment['SERVER_PORT']) ? (int) $environment['SERVER_PORT'] : NULL); $uri->setUsername(isset($environment['PHP_AUTH_USER']) ? $environment['PHP_AUTH_USER'] : NULL); $uri->setPassword(isset($environment['PHP_AUTH_PW']) ? $environment['PHP_AUTH_PW'] : NULL); $requestUriParts = explode('?', $environment['REQUEST_URI'], 2); $uri->setPath($requestUriParts[0]); if (isset($requestUriParts[1])) { $queryParts = explode('#', $requestUriParts[1], 2); $uri->setQuery($queryParts[0]); $uri->setFragment(isset($queryParts[1]) ? $queryParts[1] : NULL); } return $uri; }