Beispiel #1
0
 /**
  * Magic method for anything called that doesn't exist
  *
  * @param string $requested_method
  * @param array  $arguments
  *
  * List of many of the possible method being called here
  * documented at the top of this class.
  */
 public function __call($requested_method, $arguments)
 {
     // Convert to snake case
     $name = strtolower(preg_replace('/(.)([A-Z])/', '$1_$2', $requested_method));
     // The first argument is the string|array|object we want to echo out
     $output = reset($arguments);
     $name = $this->applyStyleMethods($name);
     // If we have fulfilled all of the requested methods and we have output, output it
     if (!strlen($name) && $this->hasOutput($output)) {
         return $this->out($output);
     }
     // If we still have something left, let's see if it's a terminal object
     if (strlen($name)) {
         if ($this->terminal_object->exists($name)) {
             // Retrieve the parser for the current set of styles
             $parser = $this->style->parser();
             // Reset the styles
             $this->style->reset();
             // Execute the terminal object
             $obj = $this->terminal_object->settings($this->settings)->parser($parser)->execute($name, $arguments);
             // If something was returned, return it
             if ($obj) {
                 return $obj;
             }
         } elseif ($this->settings->exists($name)) {
             $this->settings->add($name, $output);
         } else {
             // If we can't find it at this point, let's fail gracefully
             return $this->out($output);
         }
     }
     return $this;
 }
Beispiel #2
0
 /**
  * Build up the terminal object and return it
  *
  * @param string $name
  * @param array $arguments
  *
  * @return object|null
  */
 protected function buildTerminalObject($name, $arguments)
 {
     // Retrieve the parser for the current set of styles
     $parser = $this->style->parser($this->util->system);
     // Reset the styles
     $this->style->reset();
     // Execute the terminal object
     $this->router->settings($this->settings);
     $this->router->parser($parser);
     $this->router->output($this->output);
     $this->router->util($this->util);
     return $this->router->execute($name, $arguments);
 }