Passed
Push — master ( 17481c...d9f781 )
by Reyo
02:57
created

AccessTokenAuthentication   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 22
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
getPlugin() 0 13 ?
A hp$0 ➔ getPlugin() 0 13 1
A hp$0 ➔ authenticate() 0 3 1
A __construct() 0 3 1
A hp$0 ➔ __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the timechimp bundle package.
7
 * (c) Connect Holland.
8
 */
9
10
namespace ConnectHolland\TimechimpBundle\Api\Authentication;
11
12
class AccessTokenAuthentication implements \Jane\OpenApiRuntime\Client\Authentication
13
{
14
    private $apiKey;
15
16
    public function __construct(string $apiKey)
17
    {
18
        $this->{'apiKey'} = $apiKey;
19
    }
20
21
    public function getPlugin(): \Http\Client\Common\Plugin
22
    {
23
        return new \Http\Client\Common\Plugin\AuthenticationPlugin(new class($this->{'apiKey'}) implements \Http\Message\Authentication {
24
            private $apiKey;
25
26
            public function __construct(string $apiKey)
27
            {
28
                $this->{'apiKey'} = $apiKey;
29
            }
30
31
            public function authenticate(\Psr\Http\Message\RequestInterface $request)
32
            {
33
                return $request->withHeader('Authorization', $this->{'apiKey'});
34
            }
35
        });
36
    }
37
}
38