Merge remote branch 'brikou/phpdoc_cookie'
* brikou/phpdoc_cookie: [HttpFoundation] added phpdoc + exception fix
This commit is contained in:
commit
e92669eb47
@ -26,6 +26,17 @@ class Cookie
|
|||||||
protected $secure;
|
protected $secure;
|
||||||
protected $httpOnly;
|
protected $httpOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the cookie
|
||||||
|
* @param string $value The value of the cookie
|
||||||
|
* @param integer|string|\DateTime $expire The time the cookie expires
|
||||||
|
* @param string $path The path on the server in which the cookie will be available on
|
||||||
|
* @param string $domain The domain that the cookie is available to
|
||||||
|
* @param Boolean $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client
|
||||||
|
* @param Boolean $httpOnly Whether the cookie will be made accessible only through the HTTP protocol
|
||||||
|
*/
|
||||||
public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)
|
public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)
|
||||||
{
|
{
|
||||||
// from PHP source code
|
// from PHP source code
|
||||||
@ -34,11 +45,11 @@ class Cookie
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
|
if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
|
||||||
throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $name));
|
throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
throw new \InvalidArgumentException('The cookie name cannot be empty');
|
throw new \InvalidArgumentException('The cookie name cannot be empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert expiration time to a Unix timestamp
|
// convert expiration time to a Unix timestamp
|
||||||
@ -94,36 +105,71 @@ class Cookie
|
|||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the cookie.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the cookie.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getValue()
|
public function getValue()
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the domain that the cookie is available to.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getDomain()
|
public function getDomain()
|
||||||
{
|
{
|
||||||
return $this->domain;
|
return $this->domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the time the cookie expires.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
public function getExpiresTime()
|
public function getExpiresTime()
|
||||||
{
|
{
|
||||||
return $this->expire;
|
return $this->expire;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the path on the server in which the cookie will be available on.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getPath()
|
public function getPath()
|
||||||
{
|
{
|
||||||
return $this->path;
|
return $this->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
|
||||||
|
*
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
public function isSecure()
|
public function isSecure()
|
||||||
{
|
{
|
||||||
return $this->secure;
|
return $this->secure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the cookie will be made accessible only through the HTTP protocol.
|
||||||
|
*
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
public function isHttpOnly()
|
public function isHttpOnly()
|
||||||
{
|
{
|
||||||
return $this->httpOnly;
|
return $this->httpOnly;
|
||||||
|
Reference in New Issue
Block a user