public function generateClass(string $className, string $templateName, array $variables = []): string
    {
        $targetPath = $this->fileManager->getRelativePathForFutureClass($className);

        if (null === $targetPath) {
            throw new \LogicException(sprintf('Could not determine where to locate the new class "%s", maybe try with a full namespace like "\\My\\Full\\Namespace\\%s"', $className, Str::getShortClassName($className)));
        }

        $variables = array_merge($variables, [
            'class_name' => Str::getShortClassName($className),
            'namespace' => Str::getNamespace($className),
        ]);

        $this->addOperation($targetPath, $templateName, $variables);

        return $targetPath;
    }
public function generateClass(string $className, string $templateName, array $variables = []): string
    {
        $targetPath = $this->fileManager->getRelativePathForFutureClass($className);

        if (null === $targetPath) {
            throw new \LogicException(sprintf('Could not determine where to locate the new class "%s", maybe try with a full namespace like "\\My\\Full\\Namespace\\%s"', $className, Str::getShortClassName($className)));
        }

        $variables = array_merge($variables, [
            'class_name' => Str::getShortClassName($className),
            'namespace' => Str::getNamespace($className),
        ]);

        $this->addOperation($targetPath, $templateName, $variables);

        return $targetPath;
    }
public function generateClass ( string $ className , string $ templateName , array $ variables = [ ] ) : string { $ targetPath = $ this -> fileManager -> getRelativePathForFutureClass ( $ className ) ; if ( null === $ targetPath ) { throw new \ LogicException ( sprintf ( 'Could not determine where to locate the new class "%s", maybe try with a full namespace like "\\My\\Full\\Namespace\\%s"' , $ className , Str :: getShortClassName ( $ className ) ) ) ; } $ variables = array_merge ( $ variables , [ 'class_name' => Str :: getShortClassName ( $ className ) , 'namespace' => Str :: getNamespace ( $ className ) , ] ) ; $ this -> addOperation ( $ targetPath , $ templateName , $ variables ) ; return $ targetPath ; }
Generate a new file for a class from a template.

@param string $className    The fully-qualified class name
@param string $templateName Template name in Resources/skeleton to use
@param array  $variables    Array of variables to pass to the template

@return string The path where the file will be created

@throws \Exception
Generate a new file for a class from a template .