diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index e5e436a..a2837d5 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -798,10 +798,9 @@ 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->value: + case ProjectType::NCC: try { $package_path = (new ProjectManager($project_detection->getProjectFilePath()))->build( @@ -824,7 +823,7 @@ throw new OperationException(sprintf('Failed to build from source %s: %s', $archive, $e->getMessage()), $e); } - case ProjectType::COMPOSER->value: + case ProjectType::COMPOSER: try { $project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options); diff --git a/src/ncc/Objects/ProjectDetectionResults.php b/src/ncc/Objects/ProjectDetectionResults.php index d31e255..a6c5934 100644 --- a/src/ncc/Objects/ProjectDetectionResults.php +++ b/src/ncc/Objects/ProjectDetectionResults.php @@ -32,27 +32,21 @@ /** * @var string */ - private $project_file_path; + private string $project_file_path; /** - * @see ProjectType - * @var string + * @var ProjectType */ - private $project_type; + private ProjectType $project_type; /** * ProjectDetectionResults Constructor * * @param string $project_file_path - * @param string $project_type + * @param ProjectType $project_type */ - public function __construct(string $project_file_path, string $project_type) + public function __construct(string $project_file_path, ProjectType $project_type) { - if(!in_array($project_type, ProjectType::ALL)) - { - throw new InvalidArgumentException(sprintf('Invalid project type "%s"', $project_type)); - } - $this->project_file_path = $project_file_path; $this->project_type = $project_type; } @@ -70,9 +64,9 @@ /** * Returns the detected project type * - * @return string + * @return ProjectType */ - public function getProjectType(): string + public function getProjectType(): ProjectType { return $this->project_type; } diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index b50b6df..e31143a 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -173,12 +173,12 @@ { if(str_ends_with($file, 'project.json')) { - return new ProjectDetectionResults($file, ProjectType::NCC->value); + return new ProjectDetectionResults($file, ProjectType::NCC); } if(str_ends_with($file, 'composer.json')) { - return new ProjectDetectionResults($file, ProjectType::COMPOSER->value); + return new ProjectDetectionResults($file, ProjectType::COMPOSER); } }