package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -46,15 +46,10 @@ final class QpContentEncoder implements ContentEncoderInterface
// transform =0D=0A to CRLF
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
switch (\ord(substr($string, -1))) {
case 0x09:
$string = substr_replace($string, '=09', -1);
break;
case 0x20:
$string = substr_replace($string, '=20', -1);
break;
}
return $string;
return match (\ord(substr($string, -1))) {
0x09 => substr_replace($string, '=09', -1),
0x20 => substr_replace($string, '=20', -1),
default => $string,
};
}
}

View File

@@ -76,7 +76,7 @@ class QpEncoder implements EncoderInterface
255 => '=FF',
];
private static $safeMapShare = [];
private static array $safeMapShare = [];
/**
* A map of non-encoded ascii characters.
@@ -85,7 +85,7 @@ class QpEncoder implements EncoderInterface
*
* @internal
*/
protected $safeMap = [];
protected array $safeMap = [];
public function __construct()
{
@@ -106,8 +106,6 @@ class QpEncoder implements EncoderInterface
}
/**
* {@inheritdoc}
*
* Takes an unencoded string and produces a QP encoded string from it.
*
* QP encoded strings have a maximum line length of 76 characters.
@@ -184,12 +182,11 @@ class QpEncoder implements EncoderInterface
private function standardize(string $string): string
{
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
switch ($end = \ord(substr($string, -1))) {
case 0x09:
case 0x20:
$string = substr_replace($string, self::QP_MAP[$end], -1);
}
return $string;
return match ($end = \ord(substr($string, -1))) {
0x09,
0x20 => substr_replace($string, self::QP_MAP[$end], -1),
default => $string,
};
}
}