Move Cookie::makeHeader() to Header::make()

This commit is contained in:
Giuseppe Criscione 2021-07-20 16:24:51 +02:00
parent f28f8ef408
commit 0c91f35119
2 changed files with 13 additions and 13 deletions

View File

@ -29,7 +29,7 @@ class Cookie
throw new InvalidArgumentException(sprintf('Invalid cookie name "%s"', $name));
}
$data = [$name => rawurlencode($value)] + static::parseOptions($options);
Header::send('Set-Cookie', static::makeHeader($data), $replace);
Header::send('Set-Cookie', Header::make($data), $replace);
}
/**
@ -80,16 +80,4 @@ class Cookie
}
return $data;
}
/**
* Make Set-Cookie header string
*/
protected static function makeHeader(array $data): string
{
$parts = [];
foreach ($data as $key => $value) {
$parts[] = is_int($key) ? $value : $key . '=' . $value;
}
return implode('; ', $parts);
}
}

View File

@ -149,4 +149,16 @@ class Header
static::send('Location', $uri);
exit;
}
/**
* Make header content
*/
public static function make(array $data): string
{
$parts = [];
foreach ($data as $key => $value) {
$parts[] = is_int($key) ? $value : $key . '=' . $value;
}
return implode('; ', $parts);
}
}