WpOrg\Requests
Cookie::__construct()
Create a new cookie object
Метод класса: Cookie{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$Cookie = new Cookie(); $Cookie->__construct( $name, $value, $attributes, $flags, $reference_time );
- $name(строка) (обязательный)
- The name of the cookie.
- $value(строка) (обязательный)
- The value for the cookie.
- $attributes(массив|\WpOrg\Requests\Utility\CaseInsensitiveDictionary)
- Associative array of attribute data
По умолчанию: [] - $flags(массив)
- The flags for the cookie. Valid keys are 'creation', 'last-access', 'persistent' and 'host-only'.
По умолчанию: [] - $reference_time(int|null)
- Reference time for relative calculations.
По умолчанию: null
Код Cookie::__construct() Cookie:: construct WP 6.6.1
public function __construct($name, $value, $attributes = [], $flags = [], $reference_time = null) { if (is_string($name) === false) { throw InvalidArgument::create(1, '$name', 'string', gettype($name)); } if (is_string($value) === false) { throw InvalidArgument::create(2, '$value', 'string', gettype($value)); } if (InputValidator::has_array_access($attributes) === false || InputValidator::is_iterable($attributes) === false) { throw InvalidArgument::create(3, '$attributes', 'array|ArrayAccess&Traversable', gettype($attributes)); } if (is_array($flags) === false) { throw InvalidArgument::create(4, '$flags', 'array', gettype($flags)); } if ($reference_time !== null && is_int($reference_time) === false) { throw InvalidArgument::create(5, '$reference_time', 'integer|null', gettype($reference_time)); } $this->name = $name; $this->value = $value; $this->attributes = $attributes; $default_flags = [ 'creation' => time(), 'last-access' => time(), 'persistent' => false, 'host-only' => true, ]; $this->flags = array_merge($default_flags, $flags); $this->reference_time = time(); if ($reference_time !== null) { $this->reference_time = $reference_time; } $this->normalize(); }