Laralib\L5scaffold\Commands\ScaffoldMakeCommand::getObjName PHP Méthode

getObjName() public méthode

Generate names
public getObjName ( string $config = 'Name' ) : mixed
$config string
Résultat mixed
    public function getObjName($config = 'Name')
    {
        $names = [];
        $args_name = $this->argument('name');
        // Name[0] = Tweet
        $names['Name'] = str_singular(ucfirst($args_name));
        // Name[1] = Tweets
        $names['Names'] = str_plural(ucfirst($args_name));
        // Name[2] = tweets
        $names['names'] = str_plural(strtolower(preg_replace('/(?<!^)([A-Z])/', '_$1', $args_name)));
        // Name[3] = tweet
        $names['name'] = str_singular(strtolower(preg_replace('/(?<!^)([A-Z])/', '_$1', $args_name)));
        if (!isset($names[$config])) {
            throw new \Exception("Position name is not found");
        }
        return $names[$config];
    }

Usage Example

 /**
  * Start make controller.
  *
  * @return void
  */
 private function start()
 {
     $name = $this->scaffoldCommandObj->getObjName('Name') . 'Controller';
     $path = $this->getPath($name, 'controller');
     if ($this->files->exists($path)) {
         return $this->scaffoldCommandObj->comment("x {$name}");
     }
     $this->makeDirectory($path);
     $this->files->put($path, $this->compileControllerStub());
     $this->scaffoldCommandObj->info('+ Controller');
 }