Authenticator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 23
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A authorizeConsumerRequestToProvider() 0 12 2
1
<?php
2
3
namespace SmartGamma\Behat\PactExtension\Context;
4
5
use SmartGamma\Behat\PactExtension\Exception\NoAuthTypeSupported;
6
7
class Authenticator
8
{
9
    /**
10
     * @param string $authType
11
     * @param string $credentials
12
     *
13
     * @return array
14
     *
15
     * @throws NoAuthTypeSupported
16
     */
17
    public function authorizeConsumerRequestToProvider(string $authType, string $credentials): array
18
    {
19
        switch ($authType) {
20
            case 'http':
21
                $headers = ['Authorization' => 'Basic ' . base64_encode($credentials)];
22
                break;
23
            default:
24
                throw new NoAuthTypeSupported('No authorization type:' . $authType . ' is supported');
25
        }
26
27
        return $headers;
28
    }
29
}
30