Phly\Http\Stream::attach PHP Метод

attach() публичный Метод

Attach a new stream/resource to the instance.
public attach ( string | resource $resource, string $mode = 'r' )
$resource string | resource
$mode string
    public function attach($resource, $mode = 'r')
    {
        $error = null;
        if (!is_resource($resource) && is_string($resource)) {
            set_error_handler(function ($e) use(&$error) {
                $error = $e;
            }, E_WARNING);
            $resource = fopen($resource, $mode);
            restore_error_handler();
        }
        if ($error) {
            throw new InvalidArgumentException('Invalid stream reference provided');
        }
        if (!is_resource($resource)) {
            throw new InvalidArgumentException('Invalid stream provided; must be a string stream identifier or resource');
        }
        $this->resource = $resource;
    }