Exemple #1
0
 /**
  * 
  * @param string $func_name
  * @param callable|\Closure $function
  */
 public function setInstanceFunction($func_name, $function)
 {
     if (!is_string($func_name) || !is_callable($function) && !is_a($function, '\\Closure')) {
         if (!is_string($func_name)) {
             throw new \InvalidArgumentException(__METHOD__ . " expects first argument to have key of type text string. Provided: " . print_r($func_name, TRUE));
         } else {
             throw new \InvalidArgumentException(__METHOD__ . " expects first argument to have value of type Callable. Provided: " . print_r($function, TRUE));
         }
     }
     $ctrlr_rest = new \ReflectionClass("\\Segment\\Controller\\ControllerRestReceipt");
     $ctrlr_record = new \ReflectionClass("\\Segment\\Controller\\ControllerRecordReceipt");
     if (isset($this->crest) && $ctrlr_rest->hasMethod($func_name)) {
         $property_n = \Segment\utilities\Utilities::convertFunctionNameToProperty($func_name);
         $this->crest->{$property_n} = $function;
     } else {
         if (isset($this->crecord) && $ctrlr_record->hasMethod($func_name)) {
             $property_n = \Segment\utilities\Utilities::convertFunctionNameToProperty($func_name);
             $this->crecord->{$func_name} = $function;
         } else {
             parent::setInstanceFunction($func_name, $function);
         }
     }
 }