PublicAppCredential   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getAccessToken() 0 4 1
A applyToRequest() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the slince/shopify-api-php
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Slince\Shopify;
13
14
use Psr\Http\Message\RequestInterface;
15
16
class PublicAppCredential implements CredentialInterface
17
{
18
    /**
19
     * @var AccessToken
20
     */
21
    protected $accessToken;
22
23
    public function __construct($accessToken)
24
    {
25
        $this->accessToken = $accessToken instanceof AccessToken ? $accessToken : new AccessToken($accessToken);
26
    }
27
28
    /**
29
     * Gets the access token.
30
     *
31
     * @return AccessToken
32
     */
33
    public function getAccessToken()
34
    {
35
        return $this->accessToken;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function applyToRequest(RequestInterface $request)
42
    {
43
        return $request->withHeader('X-Shopify-Access-Token', (string)$this->getAccessToken());
44
    }
45
}