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

MoipOAuth   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A before_request() 0 4 1
A __construct() 0 4 1
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