Convert ProjectTemplates constants to enum cases

This commit is contained in:
netkas 2024-09-14 00:12:55 -04:00
parent e98b949b7d
commit 2a16b2de6b
3 changed files with 7 additions and 15 deletions

View file

@ -292,9 +292,9 @@
} }
Console::out(PHP_EOL . 'Available Templates:'); Console::out(PHP_EOL . 'Available Templates:');
foreach(ProjectTemplates::ALL as $template) foreach(ProjectTemplates::cases() as $template)
{ {
Console::out(' ' . $template); Console::out(' ' . $template->value);
} }
return 0; return 0;

View file

@ -22,23 +22,15 @@
namespace ncc\Enums; namespace ncc\Enums;
final class ProjectTemplates enum ProjectTemplates : string
{ {
/** /**
* A template that is used to create a PHP library project * A template that is used to create a PHP library project
*/ */
public const PHP_LIBRARY = 'phplib'; case PHP_LIBRARY = 'phplib';
/** /**
* A template that is used to create a PHP CLI application project * A template that is used to create a PHP CLI application project
*/ */
public const PHP_CLI = 'phpcli'; case PHP_CLI = 'phpcli';
/**
* An array of all the available project templates
*/
public const ALL = [
self::PHP_LIBRARY,
self::PHP_CLI
];
} }

View file

@ -185,11 +185,11 @@
{ {
switch(strtolower($template_name)) switch(strtolower($template_name))
{ {
case ProjectTemplates::PHP_CLI: case ProjectTemplates::PHP_CLI->value:
CliTemplate::applyTemplate($this); CliTemplate::applyTemplate($this);
break; break;
case ProjectTemplates::PHP_LIBRARY: case ProjectTemplates::PHP_LIBRARY->value:
LibraryTemplate::applyTemplate($this); LibraryTemplate::applyTemplate($this);
break; break;