/**
* Generate a list of all tokens in the final header.
*/
protected function toTokens(string
$string = null
): array
{ $string ??=
$this->
getBodyAsString();
$tokens =
[];
// Generate atoms; split at all invisible boundaries followed by WSP
foreach (preg_split('~(?=[ \t])~',
$string) as $token) { $newTokens =
$this->
generateTokenLines($token);
foreach ($newTokens as $newToken) { $tokens[] =
$newToken;
} } return $tokens;
} /**
* Takes an array of tokens which appear in the header and turns them into
* an RFC 2822 compliant string, adding FWSP where needed.
*
* @param string[] $tokens
*/