src/Support/Str.php
public static function streamGetContents($data): string
    {
        // check if it's actually a resource, we can directly convert
        // string without any issue.
        if (! \is_resource($data)) {
            return $data;
        }

        // Get the content from stream.
        $hex = \stream_get_contents($data);

        // For some reason hex would always start with 'x' and if we
        // don't filter out this char, it would mess up hex to string
        // conversion.
        if (\preg_match('/^x(.*)$/', $hex, $matches)) {
            $hex = $matches[1];
        }

        // Check if it's actually a hex string before trying to convert.
        if (! \ctype_xdigit($hex)) {
            return $hex;
        }

        return static::fromHex($hex);
    }
public static function streamGetContents($data): string
    {
        // check if it's actually a resource, we can directly convert
        // string without any issue.
        if (! \is_resource($data)) {
            return $data;
        }

        // Get the content from stream.
        $hex = \stream_get_contents($data);

        // For some reason hex would always start with 'x' and if we
        // don't filter out this char, it would mess up hex to string
        // conversion.
        if (\preg_match('/^x(.*)$/', $hex, $matches)) {
            $hex = $matches[1];
        }

        // Check if it's actually a hex string before trying to convert.
        if (! \ctype_xdigit($hex)) {
            return $hex;
        }

        return static::fromHex($hex);
    }
public static function streamGetContents ( $ data ) : string { // check if it's actually a resource, we can directly convert // string without any issue. if ( ! \ is_resource ( $ data ) ) { return $ data ; } // Get the content from stream. $ hex = \ stream_get_contents ( $ data ) ; // For some reason hex would always start with 'x' and if we // don't filter out this char, it would mess up hex to string // conversion. if ( \ preg_match ( '/^x(.*)$/' , $ hex , $ matches ) ) { $ hex = $ matches [ 1 ] ; } // Check if it's actually a hex string before trying to convert. if ( ! \ ctype_xdigit ( $ hex ) ) { return $ hex ; } return static :: fromHex ( $ hex ) ; }
Convert filter to string, this process is required to filter stream
data return from Postgres where blob type schema would actually use
BYTEA and convert the string to stream.

@param  mixed  $data

@return string
Convert filter to string this process is required to filter stream data return from Postgres where blob type schema would actually use BYTEA and convert the string to stream .