CertificateAuthenticator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A authenticate() 0 7 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the AppleApnPush package
7
 *
8
 * (c) Vitaliy Zhuk <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace Apple\ApnPush\Protocol\Http\Authenticator;
15
16
use Apple\ApnPush\Certificate\CertificateInterface;
17
use Apple\ApnPush\Protocol\Http\Request;
18
19
/**
20
 * Authenticate request via certificate
21
 */
22
class CertificateAuthenticator implements AuthenticatorInterface
23
{
24
    /**
25
     * @var CertificateInterface
26
     */
27
    private $certificate;
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param CertificateInterface $certificate
33
     */
34
    public function __construct(CertificateInterface $certificate)
35
    {
36
        $this->certificate = $certificate;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function authenticate(Request $request): Request
43
    {
44
        $request = $request->withCertificate($this->certificate->getPath());
45
        $request = $request->withCertificatePassPhrase($this->certificate->getPassPhrase());
46
47
        return $request;
48
    }
49
}
50