function CharacterStream::read
1 call to CharacterStream::read()
- CharacterStream::readBytes in vendor/
symfony/ mime/ CharacterStream.php
File
-
vendor/
symfony/ mime/ CharacterStream.php, line 102
Class
- CharacterStream
- @author Fabien Potencier <fabien@symfony.com> @author Xavier De Cock <xdecock@gmail.com>
Namespace
Symfony\Component\MimeCode
public function read(int $length) : ?string {
if ($this->currentPos >= $this->charCount) {
return null;
}
$length = $this->currentPos + $length > $this->charCount ? $this->charCount - $this->currentPos : $length;
if ($this->fixedWidth > 0) {
$len = $length * $this->fixedWidth;
$ret = substr($this->data, $this->currentPos * $this->fixedWidth, $len);
$this->currentPos += $length;
}
else {
$end = $this->currentPos + $length;
$end = min($end, $this->charCount);
$ret = '';
$start = 0;
if ($this->currentPos > 0) {
$start = $this->map['p'][$this->currentPos - 1];
}
$to = $start;
for (; $this->currentPos < $end; ++$this->currentPos) {
if (isset($this->map['i'][$this->currentPos])) {
$ret .= substr($this->data, $start, $to - $start) . '?';
$start = $this->map['p'][$this->currentPos];
}
else {
$to = $this->map['p'][$this->currentPos];
}
}
$ret .= substr($this->data, $start, $to - $start);
}
return $ret;
}