From 28ff80dd415a65c913efde486441e13db9dbcfc2 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:22:25 -0400 Subject: [PATCH] Convert HttpRequestType constants to enum cases --- src/ncc/Classes/GiteaExtension/GiteaRepository.php | 10 +++++----- src/ncc/Classes/GithubExtension/GithubRepository.php | 10 +++++----- src/ncc/Classes/GitlabExtension/GitlabRepository.php | 10 +++++----- .../Classes/PackagistExtension/PackagistRepository.php | 4 ++-- src/ncc/Enums/Types/HttpRequestType.php | 10 +++++----- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 2b11774..4260a4b 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -105,7 +105,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -189,7 +189,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -249,7 +249,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -340,7 +340,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -436,7 +436,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index 1177510..ddccce8 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -104,7 +104,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -186,7 +186,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_NOBODY => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers, CURLOPT_FOLLOWLOCATION => true ]); @@ -249,7 +249,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -331,7 +331,7 @@ $headers = self::injectAuthentication($authentication, $curl, $headers); } - curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, CURLOPT_HTTPHEADER => $headers]); + curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers]); Console::outDebug(sprintf('Fetching release package for %s/%s/%s from %s', $group, $project, $release, $endpoint)); $response = self::processHttpResponse($curl, $group, $project); @@ -415,7 +415,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index 0865dff..e1fb48a 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -106,7 +106,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -190,7 +190,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_NOBODY => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers, CURLOPT_FOLLOWLOCATION => true ]); @@ -252,7 +252,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -335,7 +335,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -420,7 +420,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Classes/PackagistExtension/PackagistRepository.php b/src/ncc/Classes/PackagistExtension/PackagistRepository.php index 902601c..d8d9e7d 100644 --- a/src/ncc/Classes/PackagistExtension/PackagistRepository.php +++ b/src/ncc/Classes/PackagistExtension/PackagistRepository.php @@ -72,7 +72,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -132,7 +132,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Enums/Types/HttpRequestType.php b/src/ncc/Enums/Types/HttpRequestType.php index 50b3eac..6892f7b 100644 --- a/src/ncc/Enums/Types/HttpRequestType.php +++ b/src/ncc/Enums/Types/HttpRequestType.php @@ -22,10 +22,10 @@ namespace ncc\Enums\Types; - final class HttpRequestType + enum HttpRequestType : string { - public const GET = 'GET'; - public const POST = 'POST'; - public const PUT = 'PUT'; - public const DELETE = 'DELETE'; + case GET = 'GET'; + case POST = 'POST'; + case PUT = 'PUT'; + case DELETE = 'DELETE'; } \ No newline at end of file