/**
* Build the directory for the class if necessary.
*
* @param string $path
* @return string
*/
protected function makeDirectory($path)// make Directory
{
if (! $this->files->isDirectory(dirname($path))) {// check null the directory is exists.
$this->files->makeDirectory(dirname($path), 0777, true, true);// make Directory.
}
}// Build the directory for the class if necessary.

/**
* Build the class with the given name.
*
* @param string $name
* @return string
*/
protected function buildClass($name)
{
$stub = $this->files->get($this->getStub());// getStub then get stub

return $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
// replace Name space stub use static and replace Class
}// build the class with the given name.

/**
* Replace the namespace for the given stub.
*
* @param string $stub
* @param string $name
* @return $this
*/
protected function replaceNamespace(&$stub, $name)// Replace the namespace for the given stub.
{
$stub = str_replace(
'DummyNamespace', $this->getNamespace($name), $stub
);// change the default namespace to the right now space

$stub = str_replace(
'DummyRootNamespace', $this->laravel->getNamespace(), $stub
);// change Root Name space use a used namespace

return $this;// return a class instance
}

/**
* Get the full namespace name for a given class.
*
* @param string $name
* @return string
*/
protected function getNamespace($name)
{
return trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\');
}// Get the full namespace for a given class.