stream_copy_to_stream

Supported Versions: PHP 5, PHP 7, PHP 8
Copies data from one stream to another
<?php stream_copy_to_stream(    resource $from,    resource $to,    ?int $length = null,    int $offset = 0): int|false
<?php     private function copyStreamToStream($source, $target): void

    {

        if (@stream_copy_to_stream($source, $target) === false) {

            throw CannotCopyStreamToStream::new(error_get_last());

        }

    }