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;
|
||||
|
||||
final class ProjectType
|
||||
enum ProjectType : string
|
||||
{
|
||||
public const COMPOSER = 'composer';
|
||||
case COMPOSER = 'composer';
|
||||
|
||||
public const NCC = 'ncc';
|
||||
|
||||
public const ALL = [
|
||||
self::COMPOSER,
|
||||
self::NCC,
|
||||
];
|
||||
case NCC = 'ncc';
|
||||
}
|
|
@ -798,9 +798,10 @@
|
|||
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())
|
||||
{
|
||||
case ProjectType::NCC:
|
||||
case ProjectType::NCC->value:
|
||||
try
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
case ProjectType::COMPOSER:
|
||||
case ProjectType::COMPOSER->value:
|
||||
try
|
||||
{
|
||||
$project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options);
|
||||
|
|
|
@ -212,12 +212,12 @@
|
|||
{
|
||||
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'))
|
||||
{
|
||||
return new ProjectDetectionResults($file, ProjectType::COMPOSER);
|
||||
return new ProjectDetectionResults($file, ProjectType::COMPOSER->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue