public function __construct($name, $value = null, $expires = 0, $maximumAge = null, $domain = null, $path = '/', $secure = false, $httpOnly = true)
{
if (preg_match(self::PATTERN_TOKEN, $name) !== 1) {
throw new \InvalidArgumentException('The parameter "name" passed to the Cookie constructor must be a valid token as per RFC 2616, Section 2.2.', 1345101977);
}
if ($expires instanceof \Datetime) {
$expires = $expires->getTimestamp();
}
if (!is_integer($expires)) {
throw new \InvalidArgumentException('The parameter "expires" passed to the Cookie constructor must be a unix timestamp or a DateTime object.', 1345108785);
}
if ($maximumAge !== null && !is_integer($maximumAge)) {
throw new \InvalidArgumentException('The parameter "maximumAge" passed to the Cookie constructor must be an integer value.', 1345108786);
}
if ($domain !== null && preg_match(self::PATTERN_DOMAIN, $domain) !== 1) {
throw new \InvalidArgumentException('The parameter "domain" passed to the Cookie constructor must be a valid domain as per RFC 6265, Section 4.1.2.3.', 1345116246);
}
if ($path !== null && preg_match(self::PATTERN_PATH, $path) !== 1) {
throw new \InvalidArgumentException('The parameter "path" passed to the Cookie constructor must be a valid path as per RFC 6265, Section 4.1.1.', 1345123078);
}
$this->name = $name;
$this->value = $value;
$this->expiresTimestamp = $expires;
$this->maximumAge = $maximumAge;
$this->domain = $domain;
$this->path = $path;
$this->secure = $secure == true;
$this->httpOnly = $httpOnly == true;
}