コード例 #1
0
ファイル: type.php プロジェクト: annaqin/eden
 /**
  * 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);
 }
コード例 #2
0
ファイル: registry.php プロジェクト: annaqin/eden
 public function __construct($data = array())
 {
     //if there is more arguments or data is not an array
     if (func_num_args() > 1 || !is_array($data)) {
         //just get the args
         $data = func_get_args();
     }
     foreach ($data as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $class = get_class($this);
         $data[$key] = $this->{$class}($value);
     }
     parent::__construct($data);
 }
コード例 #3
0
ファイル: abstract.php プロジェクト: annaqin/eden
 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;
 }
コード例 #4
0
ファイル: eden.php プロジェクト: rafamaxber/Arkay-sync
if(!class_exists('Eden_Registry')){class Eden_Registry extends Eden_Type_Array{public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($data=array()){if(func_num_args() > 1 || !is_array($data)){$data=func_get_args();}foreach($data as $key=>$value){if(!is_array($value)){continue;}$class=get_class($this);$data[$key]=$this->$class($value);}parent::__construct($data);}public function __toString(){return json_encode($this->getArray());}public function get($modified=true){$args=func_get_args();if(count($args)==0){return $this;}$key=array_shift($args);if($key===false){if(count($args)==0){return $this->getArray();}$modified=$key;$key=array_shift($args);array_unshift($args,$modified);}if(!isset($this->_data[$key])){return NULL;}if(count($args)==0){return $this->_data[$key];}if($this->_data[$key] instanceof Eden_Registry){return call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);}return NULL;}public function getArray($modified=true){$array=array();foreach($this->_data as $key=>$data){if($data instanceof Eden_Registry){$array[$key]=$data->getArray($modified);continue;}$array[$key]=$data;}return $array;}public function isKey(){$args=func_get_args();if(count($args)==0){return $this;}$key=array_shift($args);if(!isset($this->_data[$key])){return false;}if(count($args)==0){return true;}if($this->_data[$key] instanceof Eden_Registry){return call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);}return false;}public function offsetGet($offset){if(!isset($this->_data[$offset])){return NULL;}if($this->_data[$offset] instanceof Eden_Registry){return $this->_data[$offset]->getArray();}return $this->_data[$offset];}public function remove(){$args=func_get_args();if(count($args)==0){return $this;}$key=array_shift($args);if(!isset($this->_data[$key])){return $this;}if(count($args)==0){unset($this->_data[$key]);return $this;}if($this->_data[$key] instanceof Eden_Registry){return call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);}return $this;}public function set($value){$args=func_get_args();if(count($args) < 2){return $this;}$key=array_shift($args);if(count($args)==1){if(is_array($args[0])){$args[0]=self::i($args[0]);}$this->_data[$key]=$args[0];return $this;}if(!isset($this->_data[$key]) || !($this->_data[$key] instanceof Eden_Registry)){$this->_data[$key]=self::i();}call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);return $this;}}}
コード例 #5
0
ファイル: eden.php プロジェクト: jpalala/startupjobs
 public function __construct($data = array())
 {
     if (func_num_args() > 1 || !is_array($data)) {
         $data = func_get_args();
     }
     foreach ($data as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $class = get_class($this);
         $data[$key] = $this->{$class}($value);
     }
     parent::__construct($data);
 }