Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
VultrAuth
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSecret
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getBearerToken
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getBearerTokenHead
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Vultr\VultrPhp;
6
7/**
8 * Authentication mechanism that holds your API key.
9 *
10 * @todo This class will eventually have to be refactored when we get around to supporting an actual OAuth authentication mechanism.
11 */
12class VultrAuth
13{
14    public const AUTHORIZATION_HEADER = 'Authorization';
15
16    private string $secret;
17
18    public function __construct(string $secret)
19    {
20        $this->secret = $secret;
21    }
22
23    public function getSecret() : string
24    {
25        return $this->secret;
26    }
27
28    public function getBearerToken() : string
29    {
30        return $this->getSecret();
31    }
32
33    public function getBearerTokenHead() : string
34    {
35        return 'Bearer '.$this->getBearerToken();
36    }
37}