YoastSEO_Vendor\GuzzleHttp\Cookie
SetCookie::fromString() public Yoast 1.0
Create a new SetCookie object from a string
{} Это метод класса: SetCookie{}
Хуков нет.
Возвращает
self.
Использование
$result = SetCookie::fromString( $cookie );
- $cookie(строка) (обязательный)
- Set-Cookie header string
Код SetCookie::fromString() SetCookie::fromString Yoast 15.6.2
public static function fromString($cookie)
{
// Create the default return array
$data = self::$defaults;
// Explode the cookie string using a series of semicolons
$pieces = \array_filter(\array_map('trim', \explode(';', $cookie)));
// The name of the cookie (first kvp) must exist and include an equal sign.
if (empty($pieces[0]) || !\strpos($pieces[0], '=')) {
return new self($data);
}
// Add the cookie pieces into the parsed data array
foreach ($pieces as $part) {
$cookieParts = \explode('=', $part, 2);
$key = \trim($cookieParts[0]);
$value = isset($cookieParts[1]) ? \trim($cookieParts[1], " \n\r\t\0\v") : \true;
// Only check for non-cookies when cookies have been found
if (empty($data['Name'])) {
$data['Name'] = $key;
$data['Value'] = $value;
} else {
foreach (\array_keys(self::$defaults) as $search) {
if (!\strcasecmp($search, $key)) {
$data[$search] = $value;
continue 2;
}
}
$data[$key] = $value;
}
}
return new self($data);
}