| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/robotics/wp-content/plugins/wp-optimize/vendor/intervention/httpauth/src/ |
Upload File : |
<?php
namespace Intervention\HttpAuth;
class Directive
{
/**
* Type of directive (basic|digest)
*
* @var string
*/
protected $type;
/**
* Array of parameters
*
* @var array
*/
protected $parameters = [];
/**
* Create new instance
*
* @param string $type
* @param array $parameters
*/
public function __construct($type, $parameters = [])
{
$this->type = $type;
$this->parameters = $parameters;
}
/**
* Format current instance
*
* @return string
*/
public function format(): string
{
return sprintf(
'%s %s',
ucfirst(strtolower($this->type)),
$this->getParametersString()
);
}
/**
* Return current type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Return value of given key from all parameters, if existing
*
* @param mixed $key
* @return mixed
*/
public function getParameter($key)
{
return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : null;
}
/**
* Format current parameters as string
*
* @return string
*/
private function getParametersString(): string
{
return implode(', ', array_map(function ($key, $value) {
return sprintf('%s="%s"', $key, $value);
}, array_keys($this->parameters), $this->parameters));
}
/**
* Cast object to string
*
* @return string
*/
public function __toString(): string
{
return $this->format();
}
}