Completed
Pull Request — master (#76)
by Thibaud
03:23
created

AuthenticatedClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 53
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getToken() 0 4 1
A call() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of Phraseanet-PHP-SDK.
5
 *
6
 * (c) Alchemy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhraseanetSDK\Http;
13
14
class AuthenticatedClient implements Client
15
{
16
    /**
17
     * @var string
18
     */
19
    private $token;
20
21
    /**
22
     * @var Client
23
     */
24
    private $client;
25
26
    /**
27
     * @param Client $client
28
     * @param string $token
29
     */
30
    public function __construct(Client $client, $token)
31
    {
32
        $this->client = $client;
33
        $this->token = $token;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getToken()
40
    {
41
        return $this->token;
42
    }
43
44
    /**
45
     *
46
     * @param string $method
47
     * @param string $path
48
     * @param array $query
49
     * @param array $postFields
50
     * @param array $files
51
     * @param array $headers
52
     * @return string
53
     */
54
    public function call(
55
        $method,
56
        $path,
57
        array $query = array(),
58
        array $postFields = array(),
59
        array $files = array(),
60
        array $headers = array()
61
    ) {
62
        $query = array_replace($query, [ 'oauth_token' => $this->token ]);
63
64
        return $this->client->call($method, $path, $query, $postFields, $files, $headers);
65
    }
66
}
67