authorizeConsumerRequestToProvider()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 7
cp 0
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
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