diff --git a/.idea/php.xml b/.idea/php.xml index aafe326..ab9e746 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -11,7 +11,6 @@ - diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 1019dc4..cd09047 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -473,23 +473,23 @@ { switch($authentication->getAuthenticationType()) { - case AuthenticationType::ACCESS_TOKEN->value: + case AuthenticationType::ACCESS_TOKEN: if($authentication instanceof AccessToken) { $headers[] = 'Authorization: token ' . $authentication->getAccessToken(); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType()->value)); - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: if($authentication instanceof UsernamePassword) { curl_setopt($curl, CURLOPT_USERPWD, $authentication->getUsername() . ':' . $authentication->getPassword()); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType()->value)); } return $headers; diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index f1d8c62..e0d122a 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -453,22 +453,22 @@ { switch($authentication->getAuthenticationType()) { - case AuthenticationType::ACCESS_TOKEN->value: + case AuthenticationType::ACCESS_TOKEN: if($authentication instanceof AccessToken) { $headers[] = 'Authorization: Bearer ' . $authentication->getAccessToken(); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType()->value)); - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: if($authentication instanceof UsernamePassword) { curl_setopt($curl, CURLOPT_USERPWD, $authentication->getUsername() . ':' . $authentication->getPassword()); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType()->value)); } return $headers; diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index 566acc6..fdc8670 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -478,7 +478,7 @@ break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType()->value)); case AuthenticationType::USERNAME_PASSWORD->value: if($authentication instanceof UsernamePassword) @@ -487,7 +487,7 @@ break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType()->value)); } return $headers; diff --git a/src/ncc/Interfaces/AuthenticationInterface.php b/src/ncc/Interfaces/AuthenticationInterface.php index c056ecd..e242c44 100644 --- a/src/ncc/Interfaces/AuthenticationInterface.php +++ b/src/ncc/Interfaces/AuthenticationInterface.php @@ -22,12 +22,14 @@ namespace ncc\Interfaces; + use ncc\Enums\Types\AuthenticationType; + interface AuthenticationInterface extends BytecodeObjectInterface { /** - * @return string + * @return AuthenticationType */ - public function getAuthenticationType(): string; + public function getAuthenticationType(): AuthenticationType; /** * @return string diff --git a/src/ncc/Objects/Vault.php b/src/ncc/Objects/Vault.php index 7a1a539..ceef7ad 100644 --- a/src/ncc/Objects/Vault.php +++ b/src/ncc/Objects/Vault.php @@ -177,10 +177,11 @@ $input = []; switch($entry->getPassword()->getAuthenticationType()) { - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: $input = ['password' => $password]; break; - case AuthenticationType::ACCESS_TOKEN->value: + + case AuthenticationType::ACCESS_TOKEN: $input = ['token' => $password]; break; } diff --git a/src/ncc/Objects/Vault/Entry.php b/src/ncc/Objects/Vault/Entry.php index 002a0e0..c25c3ef 100644 --- a/src/ncc/Objects/Vault/Entry.php +++ b/src/ncc/Objects/Vault/Entry.php @@ -103,7 +103,7 @@ switch($this->password->getAuthenticationType()) { - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: if(!($this->password instanceof UsernamePassword)) { return false; @@ -129,7 +129,7 @@ return $username === $this->password->getUsername() && $password === $this->password->getPassword(); - case AuthenticationType::ACCESS_TOKEN->value: + case AuthenticationType::ACCESS_TOKEN: if(!($this->password instanceof AccessToken)) { return false; diff --git a/src/ncc/Objects/Vault/Password/AccessToken.php b/src/ncc/Objects/Vault/Password/AccessToken.php index 9794a67..80d3b2b 100644 --- a/src/ncc/Objects/Vault/Password/AccessToken.php +++ b/src/ncc/Objects/Vault/Password/AccessToken.php @@ -67,10 +67,9 @@ /** * @inheritDoc */ - public function getAuthenticationType(): string + public function getAuthenticationType(): AuthenticationType { - // TODO: Could return the enum case here - return AuthenticationType::ACCESS_TOKEN->value; + return AuthenticationType::ACCESS_TOKEN; } /** diff --git a/src/ncc/Objects/Vault/Password/UsernamePassword.php b/src/ncc/Objects/Vault/Password/UsernamePassword.php index 29ed958..04ad5bb 100644 --- a/src/ncc/Objects/Vault/Password/UsernamePassword.php +++ b/src/ncc/Objects/Vault/Password/UsernamePassword.php @@ -94,10 +94,9 @@ /** * @inheritDoc */ - public function getAuthenticationType(): string + public function getAuthenticationType(): AuthenticationType { - // TODO: Could return the enum here - return AuthenticationType::USERNAME_PASSWORD->value; + return AuthenticationType::USERNAME_PASSWORD; } /**