Add a method for getting an SplFileObject pointing to a Horde_Support_StringStream
authorChuck Hagenbuch <chuck@horde.org>
Wed, 23 Sep 2009 20:32:07 +0000 (16:32 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Wed, 23 Sep 2009 20:32:07 +0000 (16:32 -0400)
framework/Support/lib/Horde/Support/StringStream.php

index a4927df..c89857b 100644 (file)
@@ -44,6 +44,17 @@ class Horde_Support_StringStream
     }
 
     /**
+     * Return an SplFileObject representing this string stream
+     *
+     * @return SplFileObject
+     */
+    public function getFileObject()
+    {
+        $context = stream_context_create(array('horde-string' => array('string' => $this)));
+        return new SplFileObject('horde-string://' . spl_object_hash($this), 'rb', false, $context);
+    }
+
+    /**
      * Install the horde-string stream wrapper if it isn't already registered.
      */
     public function installWrapper()