Overview

Packages

  • Support

Classes

  • Horde_Support_Array
  • Horde_Support_Backtrace
  • Horde_Support_CombineStream
  • Horde_Support_ConsistentHash
  • Horde_Support_Guid
  • Horde_Support_Inflector
  • Horde_Support_Memory
  • Horde_Support_Numerizer
  • Horde_Support_Numerizer_Locale_Base
  • Horde_Support_Numerizer_Locale_De
  • Horde_Support_Numerizer_Locale_Pt
  • Horde_Support_Randomid
  • Horde_Support_Stack
  • Horde_Support_StringStream
  • Horde_Support_Stub
  • Horde_Support_Timer
  • Horde_Support_Uuid
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Provides access to the Combine stream wrapper.
 4:  *
 5:  * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * @author   Michael Slusarz <slusarz@horde.org>
 8:  * @license  http://www.horde.org/licenses/bsd BSD
 9:  * @category Horde
10:  * @package  Support
11:  */
12: 
13: /**
14:  * @author   Michael Slusarz <slusarz@horde.org>
15:  * @license  http://www.horde.org/licenses/bsd BSD
16:  * @category Horde
17:  * @package  Support
18:  */
19: class Horde_Support_CombineStream implements Horde_Stream_Wrapper_CombineStream
20: {
21:     /**
22:      * Data.
23:      *
24:      * @var array
25:      */
26:     protected $_data;
27: 
28:     /**
29:      * Constructor
30:      *
31:      * @param array $data  An array of strings and/or streams to combine into
32:      *                     a single stream.
33:      */
34:     public function __construct($data)
35:     {
36:         $this->installWrapper();
37:         $this->_data = $data;
38:     }
39: 
40:     /**
41:      * Return a stream handle to this stream.
42:      *
43:      * @return resource
44:      */
45:     public function fopen()
46:     {
47:         $context = stream_context_create(array('horde-combine' => array('data' => $this)));
48:         return fopen('horde-combine://' . spl_object_hash($this), 'rb', false, $context);
49:     }
50: 
51:     /**
52:      * Return an SplFileObject representing this stream
53:      *
54:      * @return SplFileObject
55:      */
56:     public function getFileObject()
57:     {
58:         $context = stream_context_create(array('horde-combine' => array('data' => $this)));
59:         return new SplFileObject('horde-combine://' . spl_object_hash($this), 'rb', false, $context);
60:     }
61: 
62:     /**
63:      * Install the horde-combine stream wrapper if it isn't already
64:      * registered.
65:      *
66:      * @throws Exception
67:      */
68:     public function installWrapper()
69:     {
70:         if (!in_array('horde-combine', stream_get_wrappers()) &&
71:             !stream_wrapper_register('horde-combine', 'Horde_Stream_Wrapper_Combine')) {
72:             throw new Exception('Unable to register horde-combine stream wrapper.');
73:         }
74:     }
75: 
76:     /**
77:      * Return a reference to the data.
78:      *
79:      * @return array
80:      */
81:     public function getData()
82:     {
83:         return $this->_data;
84:     }
85: 
86: }
87: 
API documentation generated by ApiGen