Exemplo n.º 1
0
 /**
  * Returns the array class
  *
  * @param array|mixed[,mixed..]
  * @return Eden_Type_Array
  */
 public function getArray($array)
 {
     $args = func_get_args();
     if (count($args) > 1 || !is_array($array)) {
         $array = $args;
     }
     return Eden_Type_Array::i($array);
 }
Exemplo n.º 2
0
 public function __call($name, $args)
 {
     $type = $this->_getMethodType($name);
     //if no type
     if (!$type) {
         //we don't process anything else
         try {
             //call the parent
             return parent::__call($name, $args);
         } catch (Eden_Error $e) {
             Eden_Type_Error::i($e->getMessage())->trigger();
         }
     }
     //case different types
     switch ($type) {
         case self::PRE:
             //if pre, we add it first into the args
             array_unshift($args, $this->_data);
             break;
         case self::POST:
             //if post, we add it last into the args
             array_push($args, $this->_data);
             break;
         case self::REFERENCE:
             //if reference, we add it first
             //into the args and call it
             call_user_func_array($name, array_merge(array(&$this->_data), $args));
             return $this;
     }
     //call the method
     $result = call_user_func_array($name, $args);
     //if the result is a string
     if (is_string($result)) {
         //if this class is a string type
         if ($this instanceof Eden_Type_String) {
             //set value
             $this->_data = $result;
             return $this;
         }
         //return string class
         return Eden_Type_String::i($result);
     }
     //if the result is an array
     if (is_array($result)) {
         //if this class is a array type
         if ($this instanceof Eden_Type_Array) {
             //set value
             $this->_data = $result;
             return $this;
         }
         //return array class
         return Eden_Type_Array::i($result);
     }
     return $result;
 }
Exemplo n.º 3
0
if(!class_exists('Eden_Type_Abstract')){abstract class Eden_Type_Abstract extends Eden_Class{const PRE='pre';const POST='post';const REFERENCE='reference';protected $_data=NULL;protected $_original=NULL;public function __call($name,$args){$type=$this->_getMethodType($name);if(!$type){try{return parent::__call($name,$args);}catch(Eden_Error $e){Eden_Type_Error::i($e->getMessage())->trigger();}}switch($type){case self::PRE: array_unshift($args,$this->_data);break;case self::POST: array_push($args,$this->_data);break;case self::REFERENCE: call_user_func_array($name,array_merge(array(&$this->_data),$args));return $this;}$result=call_user_func_array($name,$args);if(is_string($result)){if($this instanceof Eden_Type_String){$this->_data=$result;return $this;}return Eden_Type_String::i($result);}if(is_array($result)){if($this instanceof Eden_Type_Array){$this->_data=$result;return $this;}return Eden_Type_Array::i($result);}return $result;}public function __construct($data){$this->_original=$this->_data=$data;}public function get($modified=true){Eden_Type_Error::i()->argument(1,'bool');return $modified ? $this->_data : $this->_original;}public function revert(){$this->_data=$this->_original;return $this;}public function set($value){$this->_data=$value;return $this;}abstract protected function _getMethodType(&$name);}}
Exemplo n.º 4
0
 public function __call($name, $args)
 {
     $type = $this->_getMethodType($name);
     if (!$type) {
         try {
             return parent::__call($name, $args);
         } catch (Eden_Error $e) {
             Eden_Type_Error::i($e->getMessage())->trigger();
         }
     }
     switch ($type) {
         case self::PRE:
             array_unshift($args, $this->_data);
             break;
         case self::POST:
             array_push($args, $this->_data);
             break;
         case self::REFERENCE:
             call_user_func_array($name, array_merge(array(&$this->_data), $args));
             return $this;
     }
     $result = call_user_func_array($name, $args);
     if (is_string($result)) {
         if ($this instanceof Eden_Type_String) {
             $this->_data = $result;
             return $this;
         }
         return Eden_Type_String::i($result);
     }
     if (is_array($result)) {
         if ($this instanceof Eden_Type_Array) {
             $this->_data = $result;
             return $this;
         }
         return Eden_Type_Array::i($result);
     }
     return $result;
 }