Convert ProjectType constants to enum cases
This commit is contained in:
parent
3d44562241
commit
86cf7467af
3 changed files with 8 additions and 12 deletions
|
@ -22,14 +22,9 @@
|
||||||
|
|
||||||
namespace ncc\Enums\Types;
|
namespace ncc\Enums\Types;
|
||||||
|
|
||||||
final class ProjectType
|
enum ProjectType : string
|
||||||
{
|
{
|
||||||
public const COMPOSER = 'composer';
|
case COMPOSER = 'composer';
|
||||||
|
|
||||||
public const NCC = 'ncc';
|
case NCC = 'ncc';
|
||||||
|
|
||||||
public const ALL = [
|
|
||||||
self::COMPOSER,
|
|
||||||
self::NCC,
|
|
||||||
];
|
|
||||||
}
|
}
|
|
@ -798,9 +798,10 @@
|
||||||
throw new OperationException(sprintf('Failed to detect project type from source %s: %s', $archive, $e->getMessage()), $e);
|
throw new OperationException(sprintf('Failed to detect project type from source %s: %s', $archive, $e->getMessage()), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: getProjectType() could return the enum case
|
||||||
switch($project_detection->getProjectType())
|
switch($project_detection->getProjectType())
|
||||||
{
|
{
|
||||||
case ProjectType::NCC:
|
case ProjectType::NCC->value:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$package_path = (new ProjectManager($project_detection->getProjectFilePath()))->build(
|
$package_path = (new ProjectManager($project_detection->getProjectFilePath()))->build(
|
||||||
|
@ -823,7 +824,7 @@
|
||||||
throw new OperationException(sprintf('Failed to build from source %s: %s', $archive, $e->getMessage()), $e);
|
throw new OperationException(sprintf('Failed to build from source %s: %s', $archive, $e->getMessage()), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ProjectType::COMPOSER:
|
case ProjectType::COMPOSER->value:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options);
|
$project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options);
|
||||||
|
|
|
@ -212,12 +212,12 @@
|
||||||
{
|
{
|
||||||
if(str_ends_with($file, 'project.json'))
|
if(str_ends_with($file, 'project.json'))
|
||||||
{
|
{
|
||||||
return new ProjectDetectionResults($file, ProjectType::NCC);
|
return new ProjectDetectionResults($file, ProjectType::NCC->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(str_ends_with($file, 'composer.json'))
|
if(str_ends_with($file, 'composer.json'))
|
||||||
{
|
{
|
||||||
return new ProjectDetectionResults($file, ProjectType::COMPOSER);
|
return new ProjectDetectionResults($file, ProjectType::COMPOSER->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue