/**
  * Create a class map.
  *
  * @param string      $subPath   The path.
  *
  * @param string|null $namespace The namespace prefix (optional).
  *
  * @return array
  */
 protected function classMapFromPath($subPath, $namespace = null)
 {
     $messages = array();
     $classMap = $this->generator->scan($subPath, null, $namespace, $messages);
     if ($messages) {
         foreach ($messages as $message) {
             $this->report->warn(new GenericViolation($message));
         }
     }
     foreach ($classMap as $class => $file) {
         try {
             $this->classMap->add($class, $file);
         } catch (ClassAlreadyRegisteredException $exception) {
             $this->report->append(new ClassAddedMoreThanOnceViolation($this->getName(), $class, array($exception->getFileName(), $file)));
         }
     }
     return $classMap;
 }
 /**
  * Retrieve a class map containing all the class maps from all registered validators.
  *
  * @return ClassMap
  */
 public function getClassMap()
 {
     $classMap = new ClassMap();
     $duplicates = array();
     foreach ($this->validators as $validator) {
         $validatorName = $validator->getName();
         $partialClassMap = $validator->getClassMap();
         foreach ($partialClassMap as $class => $file) {
             try {
                 $classMap->add($class, $file);
                 $duplicates[$class][$validatorName] = $file;
             } catch (ClassAlreadyRegisteredException $exception) {
                 $duplicates[$class][$validatorName] = $file;
             }
         }
     }
     foreach ($duplicates as $class => $files) {
         if (count($files) === 1) {
             continue;
         }
         $this->report->error(new ClassAddedMoreThanOnceViolation(implode(', ', array_keys($files)), $class, $files));
     }
     return $classMap;
 }