Completed
Pull Request — master (#42)
by
unknown
02:42
created

MoipOAuth::before_request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 5
1
<?php
2
3
namespace Moip;
4
5
use Requests_Hooks;
6
7
class MoipOAuth implements MoipAuthentication
8
{
9
    /**
10
     * Access Token.
11
     *
12
     * @var string
13
     */
14
    private $accessToken;
15
16
    /**
17
     * Create a new MoipOAuth instance.
18
     *
19
     * @param string $accessToken
20
     */
21
    public function __construct($accessToken)
22
    {
23
        $this->accessToken = $accessToken;
24
    }
25
26
    /**
27
     * Register hooks as needed.
28
     *
29
     * This method is called in {@see Requests::request} when the user has set
30
     * an instance as the 'auth' option. Use this callback to register all the
31
     * hooks you'll need.
32
     *
33
     * @see Requests_Hooks::register
34
     *
35
     * @param Requests_Hooks $hooks Hook system
36
     */
37
    public function register(Requests_Hooks &$hooks)
38
    {
39
        $hooks->register('requests.before_request', [&$this, 'before_request']);
40
    }
41
42
    /**
43
     * Sets the authentication header.
44
     *
45
     * @param string       $url
46
     * @param array        $headers
47
     * @param array|string $data
48
     * @param string       $type
49
     * @param array        $options
50
     */
51
    public function before_request(&$url, &$headers, &$data, &$type, &$options)
3 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
        $headers['Authorization'] = 'OAuth '.$this->accessToken;
54
    }
55
}
56