Exemplo n.º 1
0
 /**
  * Build the Class Map
  *
  * @param string $format
  *   Output Format from Available Formats
  *
  * @param mixed|optional $options
  *   List of Options to affect Database Drivers. Acceptable values are:
  *
  *   <p>
  *
  *       <ul>
  *
  *           <li>Associative and multidimensional array</li>
  *
  *           <li>
  *
  *               An {@link http://php.net/manual/en/reserved.classes.php stdClass Object}
  *
  *           </li>
  *
  *           <li>A well formed Next\Components\Parameter Object</li>
  *
  *       </ul>
  *
  *   </p>
  *
  *   <p>There are no Common Options defined so far.</p>
  *
  *   <p>
  *       All the arguments taken in consideration are defined in
  *       and by factored classes
  *   </p>
  *
  * @see Next\Components\Parameter
  *
  * @return mixed|void
  *   If chosen format allow the result to be returned, it will
  *   accordingly to the its rules
  *
  *   Otherwise, nothing is returned
  *
  * @throws Next\Tools\ClassMapper\ClassMapperException
  *   Invalid or unsupported Mapping Format
  */
 public function build($format, $options = NULL)
 {
     if (!in_array((string) $format, $this->available)) {
         throw ClassMapperException::unknown();
     }
     // Building Definitions
     $map = new \stdClass();
     $iterator =& $this;
     iterator_apply($iterator, function () use($iterator, $map) {
         $file = $iterator->current();
         $namespace = '';
         if (!empty($file->namespace)) {
             $namespace = sprintf('%s\\', $file->namespace);
         }
         $classname = $namespace . $file->classname;
         $map->{$classname} = $file->getRealPath();
         return TRUE;
     });
     // Building Output Format Classname
     $class = sprintf('Next\\Tools\\ClassMapper\\%s', (string) $format);
     // Instantiating Object
     $instance = new $class($options);
     // Building!
     return $instance->build(ArrayUtils::map($map));
 }