Exemple #1
0
 /**
  * Using the magic PHP method __call, as the engine for our 'mapping' scheme;
  *
  * This method, __call, will make a call to a user-defined-function or a PHP-specific function, and process the result, while
  * trying to map the returned result to one of our DataTypes: for short, if the return result is compatible to one of our
  * DataTypes which should be by default, it will return an object of that kind, assuring ST (strong types);
  *
  * In simple terms, it's a nice way to retrieve the result of an action, and making sure the chain is still working. It will
  * return a basic DT, defined in RA, meaning that a return type can make the method-chain go further. Oh, and I forgot to tell
  * you, THE MECHANISM ISN'T RESTRICTED JUST TO PHP FUNCTIONS, MEANING: that if you define a CLASS, or a function that can
  * be called compatible with how call_user_func/call_user_func_array CALLs them, than the power of the mapping mechanism
  * is infinite by definition;
  *
  * Why?! Think of inheritance, what can be done if we're able to call a static method of one of our children?!
  * You guessed, it helps us do 'magic' things ... that are truly ... 'magic' :D. We will document this in a
  * tutorial, because the concept is so complicated in how it was developed, but so simple in how you're going to use it,
  * as it's a shame to let it pass by. The next documentation revision will add the necessary example code;
  *
  * @return mixed Does a call to the user-defined-function and processes the result ...
  * @param string $nameOfHook Name of the invoked method;
  * @param string $argumentsOfHook Arguments passed to that invoked method, that are in a numerically indexed array;
  */
 public function __CALL($nameOfHook, $argumentsOfHook)
 {
     // Get the current CLASS;
     self::$objCLASS = get_class($this);
     // Mapping PHP to DataTypes;
     if (isset(self::$objFuncMapper[$nameOfHook])) {
         // Map to PHPF:
         return CALL_USER_FUNC(self::$objCLASS, $this, $nameOfHook, self::$objFuncMapper[$nameOfHook], $argumentsOfHook);
     } else {
         // Map to USER:
         return CALL_USER_FUNC($nameOfHook, $this, $argumentsOfHook);
     }
 }