public function StreamEncoder::encode in Replication 8
Same name and namespace in other branches
- 8.2 src/Encoder/StreamEncoder.php \Drupal\replication\Encoder\StreamEncoder::encode()
File
- src/
Encoder/ StreamEncoder.php, line 28
Class
Namespace
Drupal\replication\EncoderCode
public function encode($data, $format, array $context = []) {
if (!is_resource($data)) {
throw new \InvalidArgumentException(sprintf('Data argument is not a resource.'));
}
$contents = stream_get_contents($data);
return $format == 'base64_stream' ? base64_encode($contents) : $contents;
}