/** * Returns the array class * * @param array|mixed[,mixed..] * * @return Eden\Type\Type\ArrayType */ public function getArray($array) { $args = func_get_args(); if (count($args) > 1 || !is_array($array)) { $array = $args; } return ArrayType::i($array); }
/** * Dermines if the missing method is actually a PHP call. * If so, call it. * * @param *string * @param *array * @return mixed */ public function __call($name, $args) { Argument::i()->test(1, 'string')->test(2, 'array'); $type = $this->getMethodType($name); //if no type if (!$type) { //we don't process anything else //call the parent return parent::__call($name, $args); } //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 StringType) { //set value $this->data = $result; return $this; } //return string class return StringType::i($result); } //if the result is an array if (is_array($result)) { //if this class is a array type if ($this instanceof ArrayType) { //set value $this->data = $result; return $this; } //return array class return ArrayType::i($result); } return $result; }