Open Journal Systems  3.3.0
Base64Encoder.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
18 {
26  public function encodeString(string $string, ?string $charset = 'utf-8', int $firstLineOffset = 0, int $maxLineLength = 0): string
27  {
28  if (0 >= $maxLineLength || 76 < $maxLineLength) {
29  $maxLineLength = 76;
30  }
31 
32  $encodedString = base64_encode($string);
33  $firstLine = '';
34  if (0 !== $firstLineOffset) {
35  $firstLine = substr($encodedString, 0, $maxLineLength - $firstLineOffset)."\r\n";
36  $encodedString = substr($encodedString, $maxLineLength - $firstLineOffset);
37  }
38 
39  return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n"));
40  }
41 }
Symfony\Component\Mime\Encoder\Base64Encoder\encodeString
encodeString(string $string, ?string $charset='utf-8', int $firstLineOffset=0, int $maxLineLength=0)
Definition: Base64Encoder.php:26
Symfony\Component\Mime\Encoder
Definition: AddressEncoderInterface.php:12
Symfony\Component\Mime\Encoder\EncoderInterface
Definition: EncoderInterface.php:17
Symfony\Component\Mime\Encoder\Base64Encoder
Definition: Base64Encoder.php:17