for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Bdf\Dsn;
/**
* DsnRequest
*/
final class DsnRequest
{
* The request uri
*
* @var string
private $url;
* The protocol to use
private $scheme;
* Host specification
* @var string|null
private $host;
* Port specification
private $port;
* User name for login
private $user;
* Password for login
private $password;
* Path info from the dsn
private $path;
* The query bag
* @var array
private $query = [];
* DsnRequest constructor.
* @param string $url
* @param string $scheme
public function __construct(string $url, string $scheme)
$this->url = $url;
$this->scheme = $scheme;
}
* Gets the request url
* @return null|string
public function getUrl(): ?string
return $this->url;
* Gets the scheme part
public function getScheme(): ?string
return $this->scheme;
* Gets the host part
public function getHost(): ?string
return $this->host;
* Sets the host part
* @param string $host
* @return $this
public function setHost(string $host): self
$this->host = $host;
return $this;
* Gets the port part
public function getPort(): ?string
return $this->port;
* Sets the port part
* @param string $port
public function setPort(string $port): self
$this->port = $port;
* Gets the user part
public function getUser(): ?string
return $this->user;
* Sets the user part
* @param string $user
public function setUser(string $user): self
$this->user = $user;
* Gets the password part
public function getPassword(): ?string
return $this->password;
* Sets the password part
* @param string $password
public function setPassword(string $password): self
$this->password = $password;
* Gets the path part
public function getPath(): ?string
return $this->path;
* Sets the path part
* @param string $path
public function setPath(string $path): self
$this->path = $path;
* Gets the query part
* @return array
public function getQuery(): array
return $this->query;
* Sets the query part
* @param array $query
public function setQuery(array $query): self
$this->query = $query;
* @param string $key
* @param mixed $default
* @return mixed
public function query(string $key, $default = null)
return $this->query[$key] ?? $default;
* Gets array representation
public function toArray(): array
return [
'scheme' => $this->scheme,
'host' => $this->host,
'port' => $this->port,
'user' => $this->user,
'password' => $this->password,
'path' => $this->path,
'query' => $this->query,
];