/**
  * Writes a class to the target module's PSR-4 root.
  *
  * @param TargetInterface $target
  *  The target module.
  * @param ClassNode $class
  *  The class to write. The path will be determined from the class'
  *  fully qualified name.
  *
  * @return string
  *  The generated path to the class.
  */
 public function writeClass(TargetInterface $target, ClassNode $class)
 {
     $class_path = ltrim($class->getName()->getAbsolutePath(), '\\');
     $path = str_replace(['Drupal\\' . $target->id(), '\\'], ['src', '/'], $class_path) . '.php';
     return $this->write($target, $path, $class->parents()->get(0));
 }