Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
Hoa\Prototype\Prototype Class Reference

Public Member Functions

 __set ($name, $value)
 
 __get ($name)
 
 __call ($name, Array $arguments)
 

Protected Member Functions

 setPrototypeClassType ($type)
 
 setPrototypeObjectType ($type)
 
 disablePrototypeClassType ()
 
 disablePrototypeObjectType ()
 

Protected Attributes

 $_classType = ''
 
 $_objectType = ''
 

Private Attributes

 $_prototype = null
 

Detailed Description

Class .

Enable to do a Prototype-based programming.

Author
Ivan Enderlin ivan..nosp@m.ende.nosp@m.rlin@.nosp@m.hoa-.nosp@m.proje.nosp@m.ct.n.nosp@m.et

Definition at line 60 of file Prototype.php.

Member Function Documentation

Hoa\Prototype\Prototype::__call (   $name,
Array  $arguments 
)

Call a prototype slot. Normally, in the Prototype-based programming, there is no difference between an attribute or a method, all is slot. But in PHP, there is a difference. So __call and __get act in the same way.

public

Parameters
string$nameSlot name.
array$argumentsSlot arguments.
Returns
mixed
Exceptions

Definition at line 182 of file Prototype.php.

182  {
183 
184  if(null === $this->_prototype)
185  throw new Exception(
186  'Call to undefined property: %s::%s().',
187  6, array(get_class($this), $name));
188 
189  $callback = array($this->_prototype, $name);
190 
191  if(is_callable($callback))
192  return call_user_func_array($callback, $arguments);
193 
194  if($this->_prototype instanceof Prototype)
195  return $this->_prototype->__call($name, $arguments);
196 
197  throw new Exception(
198  'Call to uncallable method %s::%s().', 7,
199  array(get_class($this), $name));
200  }
Hoa\Prototype\Prototype::__get (   $name)

Get a prototype slot value.

public

Parameters
string$nameSlot name.
Returns
mixed
Exceptions

Definition at line 147 of file Prototype.php.

147  {
148 
149  if(true === property_exists($this, 'prototype'))
150  throw new Exception(
151  'You must not have a prototype attribute declared in your ' .
152  'class.', 3);
153 
154  if(null === $this->_prototype)
155  throw new Exception(
156  'Undefined property: %s::%s.',
157  4, array(get_class($this), $name));
158 
159  if(true === property_exists($this->_prototype, $name))
160  return $this->_prototype->$name;
161 
162  if($this->_prototype instanceof Prototype)
163  return $this->_prototype->__get($name);
164 
165  throw new Exception(
166  'Undefined property: %s::%s.',
167  5, array(get_class($this), $name));
168  }
Hoa\Prototype\Prototype::__set (   $name,
  $value 
)

Set the prototype or attempt to set a prototype slot.

public

Parameters
string$name'prototype' if want to set the prototype, slot name else.
mixed$valueThe prototype object or the slot value.
Returns
mixed
Exceptions

Definition at line 100 of file Prototype.php.

100  {
101 
102  if(true === property_exists($this, 'prototype'))
103  throw new Exception(
104  'You must not have a prototype attribute declared in your ' .
105  'class.', 0);
106 
107  if(strtolower($name) == 'prototype') {
108 
109  $out = is_object($value);
110 
111  if($out && $this->_objectType != '')
112  $out = $value instanceof $this->_objectType;
113 
114  if($out && $this->_classType != '')
115  $out &= strtolower(get_class($value))
116  == strtolower($this->_classType);
117 
118  if(false === (bool) $out)
119  throw new Exception(
120  'Cannot set the prototype %s; it must be an object of ' .
121  'type %s and a class of type %s.',
122  1, array(
123  get_class($value),
124  $this->_objectType,
125  $this->_classType
126  ));
127 
128  return $this->_prototype = $value;
129  }
130 
131  if(null === $this->_prototype)
132  throw new Exception(
133  'Undefined property: %s::%s.',
134  2, array(get_class($this), $name));
135 
136  return $this->_prototype->$name = $value;
137  }
Hoa\Prototype\Prototype::disablePrototypeClassType ( )
protected

Disable the prototype class type.

protected

Returns
string

Definition at line 238 of file Prototype.php.

238  {
239 
240  return $this->setPrototypeClassType(null);
241  }

Here is the call graph for this function:

Hoa\Prototype\Prototype::disablePrototypeObjectType ( )
protected

Disable the prototype object type.

protected

Returns
string

Definition at line 249 of file Prototype.php.

249  {
250 
251  return $this->setPrototypeObjectType(null);
252  }

Here is the call graph for this function:

Hoa\Prototype\Prototype::setPrototypeClassType (   $type)
protected

Set the prototype class type.

protected

Parameters
string$typePrototype class type.
Returns
string

Definition at line 209 of file Prototype.php.

209  {
210 
211  $old = $this->_classType;
212  $this->_classType = $type;
213 
214  return $old;
215  }

Here is the caller graph for this function:

Hoa\Prototype\Prototype::setPrototypeObjectType (   $type)
protected

Set the prototype object type.

protected

Parameters
string$typePrototype object type.
Returns
string

Definition at line 224 of file Prototype.php.

224  {
225 
226  $old = $this->_objectType;
227  $this->_objectType = $type;
228 
229  return $old;
230  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Prototype\Prototype::$_classType = ''
protected

Definition at line 79 of file Prototype.php.

Hoa\Prototype\Prototype::$_objectType = ''
protected

Definition at line 86 of file Prototype.php.

Hoa\Prototype\Prototype::$_prototype = null
private

Definition at line 72 of file Prototype.php.


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