Hoa central
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Hoa\Stream\Context Class Reference

Public Member Functions

 getId ()
 
 setOptions (Array $options)
 
 setParameters (Array $parameters)
 
 getOptions ()
 
 getParameters ()
 
 getContext ()
 

Static Public Member Functions

static getInstance ($id)
 
static contextExists ($id)
 

Protected Member Functions

 __construct ($id)
 

Protected Attributes

 $_id = null
 

Static Protected Attributes

static $_instances = []
 

Detailed Description

Class .

Make a multiton of stream contexts.

Definition at line 47 of file Context.php.

Constructor & Destructor Documentation

Hoa\Stream\Context::__construct (   $id)
protected

Construct a context.

Returns
void

Definition at line 70 of file Context.php.

71  {
72  $this->_id = $id;
73  $this->_context = stream_context_create();
74 
75  return;
76  }

Member Function Documentation

static Hoa\Stream\Context::contextExists (   $id)
static

Check if a context exists.

Parameters
string$idID.
Returns
bool

Definition at line 114 of file Context.php.

115  {
116  return array_key_exists($id, static::$_instances);
117  }

Here is the caller graph for this function:

Hoa\Stream\Context::getContext ( )

Get context as a resource.

Returns
resource

Definition at line 168 of file Context.php.

169  {
170  return $this->_context;
171  }

Here is the caller graph for this function:

Hoa\Stream\Context::getId ( )

Get context ID.

Returns
string

Definition at line 103 of file Context.php.

104  {
105  return $this->_id;
106  }
static Hoa\Stream\Context::getInstance (   $id)
static

Multiton.

Parameters
string$idID.
Returns
Exceptions

Definition at line 85 of file Context.php.

86  {
87  if (empty($id)) {
88  throw new Exception('Context ID must not be null.', 0);
89  }
90 
91  if (false === static::contextExists($id)) {
92  static::$_instances[$id] = new static($id);
93  }
94 
95  return static::$_instances[$id];
96  }

Here is the caller graph for this function:

Hoa\Stream\Context::getOptions ( )

Get options.

Returns
array

Definition at line 148 of file Context.php.

149  {
150  return stream_context_get_options($this->getContext());
151  }

Here is the call graph for this function:

Hoa\Stream\Context::getParameters ( )

Get parameters.

Returns
array

Definition at line 158 of file Context.php.

159  {
160  return stream_context_get_params($this->getContext());
161  }

Here is the call graph for this function:

Hoa\Stream\Context::setOptions ( Array  $options)

Set options. Please, see http://php.net/context.

Parameters
array$optionsOptions.
Returns
bool

Definition at line 126 of file Context.php.

127  {
128  return stream_context_set_option($this->getContext(), $options);
129  }

Here is the call graph for this function:

Hoa\Stream\Context::setParameters ( Array  $parameters)

Set parameters. Please, see http://php.net/context.params.

Parameters
array$parametersParameters.
Returns
bool

Definition at line 138 of file Context.php.

139  {
140  return stream_context_set_params($this->getContext(), $parameters);
141  }

Here is the call graph for this function:

Member Data Documentation

Hoa\Stream\Context::$_id = null
protected

Definition at line 54 of file Context.php.

Hoa\Stream\Context::$_instances = []
staticprotected

Definition at line 61 of file Context.php.


The documentation for this class was generated from the following file: