Mercurial > packages > magicforger
diff src/Replacer.php @ 2:cf9993c5c7df
Updated .vimrc for some helper commands.
updated the Base Generator
Brought the controller generator into the package
created an example generator, but it needs some work.
| author | luka |
|---|---|
| date | Sun, 25 Jun 2023 14:45:15 -0400 |
| parents | ca36acd2bef2 |
| children | 6468684362c2 |
line wrap: on
line diff
--- a/src/Replacer.php Sat Jun 24 01:08:01 2023 -0400 +++ b/src/Replacer.php Sun Jun 25 14:45:15 2023 -0400 @@ -4,89 +4,95 @@ use Illuminate\Support\Str; -class Replacer { - +class Replacer +{ /** * Cached replacements for re-use. * * @var array */ - protected $replacement_cache = []; + protected $replacement_cache = []; + - /** - * Prefix and Suffix for controller. - * Usage is up to the user. + * Prefix and Suffix for controller. + * Usage is up to the user. * * @var string */ - protected $controller_prefix = ""; + protected $controller_prefix = ""; /** - * Prefix and Suffix for controller. - * Usage is up to the user. + * Prefix and Suffix for controller. + * Usage is up to the user. * * @var string */ - protected $controller_suffix = "Controller"; + protected $controller_suffix = "Controller"; /** - * The lowest level to show log outputs. + * The lowest level to show log outputs. * * @var int */ - private $log_level = 1; + private $log_level = 1; - public function __construct() { - /* parent::__construct(); */ - } + public function __construct() + { + /* parent::__construct(); */ + } - /** - * Model names are generated in uppercase first Camel case - */ - public function model_name(string $name) : string { - return Str::singular(Str::studly($name)); - } + /** + * Model names are generated in uppercase first Camel case + */ + public function model_name(string $name): string + { + return Str::singular(Str::studly($name)); + } - /** - * Controller names are generated in uppercase first Camel case - * and wrapped in the prefix and suffix - */ - public function controller_name(string $name) : string { - return $this->controller_prefix . - $this->model_name($name) . - $this->controller_suffix; - } + /** + * Controller names are generated in uppercase first Camel case + * and wrapped in the prefix and suffix + */ + public function controller_name(string $name): string + { + return $this->controller_prefix . + $this->model_name($name) . + $this->controller_suffix; + } - /** - * Breaks up a string and makes it human readable - * - * This function assumes that the inputted name is camel case - */ - public function human_readable(string $name) : string { - return Str::title(Str::replace('_', ' ', $name)); - } + /** + * Breaks up a string and makes it human readable + * + * This function assumes that the inputted name is camel case + */ + public function human_readable(string $name): string + { + return Str::title(Str::replace('_', ' ', $name)); + } - /** - * Breaks up a string and makes it human readable and lowecase - * - * This function assumes that the inputted name is camel case - */ - public function human_readable_lc(string $name) : string { - return Str::lower($this->human_readable($name)); - } + /** + * Breaks up a string and makes it human readable and lowecase + * + * This function assumes that the inputted name is camel case + */ + public function human_readable_lc(string $name): string + { + return Str::lower($this->human_readable($name)); + } - /** - * Outputs a log for the replacements based on log level. - */ - public function log(string $str, int $log_level = 1) : void { + /** + * Outputs a log for the replacements based on log level. + */ + public function log(string $str, int $log_level = 1): void + { - if($this->log_level <= $log_level) { - print($str . "\n"); - } + if($this->log_level <= $log_level) { + print($str . "\n"); + } - } + } }
