/**
  * Loads a new formatter
  *
  * @param   string  $format     The formatter name
  * @throws  \MarkdownExtended\Exception\InvalidArgumentException if the class can not be found
  */
 public function load($format)
 {
     $cls_name = $format;
     if (!class_exists($cls_name)) {
         $cls_name = '\\MarkdownExtended\\OutputFormat\\' . Helper::toCamelCase($format);
     }
     if (!class_exists($cls_name)) {
         throw new InvalidArgumentException(sprintf('Output format "%s" not found', $format));
     }
     $cls = new $cls_name();
     if (Kernel::validate($cls, Kernel::TYPE_OUTPUTFORMAT, $format)) {
         $this->setFormatter($cls);
     }
 }
 /**
  * Global gamut's method runner
  *
  * @param string $class
  * @param string $method
  * @param string $text
  *
  * @return string
  *
  * @throws  \MarkdownExtended\Exception\UnexpectedValueException if `$gamut` doesn't implement the required method
  *              or class can not be found
  */
 protected function _runClassMethod($class, $method, $text)
 {
     if ($this->isCached($class)) {
         $_obj = $this->getCache($class);
     } else {
         if (!class_exists($class)) {
             throw new UnexpectedValueException(sprintf('Gamut class "%s" not found', $class));
         }
         $_obj = new $class();
         Kernel::validate($_obj, Kernel::TYPE_GAMUT, $class);
         $this->setCache($class, $_obj);
     }
     $method = $method ?: $_obj->getDefaultMethod();
     if (!method_exists($_obj, $method)) {
         throw new UnexpectedValueException(sprintf('Method "%s" does not exist in class "%s"', $method, $class));
     }
     $text = call_user_func(array($_obj, $method), $text);
     return $text;
 }