Completed
Push — develop ( de0fb5...78995e )
by Risan Bagja
01:33
created

OAuth1::buildAuthorizationUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Risan\OAuth1;
4
5
use InvalidArgumentException;
6
use Risan\OAuth1\Request\RequestFactoryInterface;
7
use Risan\OAuth1\Credentials\TemporaryCredentials;
8
use Risan\OAuth1\Credentials\CredentialsFactoryInterface;
9
10
class OAuth1 implements OAuth1Interface
11
{
12
    /**
13
     * The HttpClientInterface instance.
14
     *
15
     * @var \Risan\OAuth1\HttpClientInterface
16
     */
17
    protected $httpClient;
18
19
    /**
20
     * The RequestFactoryInterface instance.
21
     *
22
     * @var \Risan\OAuth1\Request\RequestFactoryInterface
23
     */
24
    protected $requestFactory;
25
26
    /**
27
     * The CredentialsFactoryInterface instance.
28
     *
29
     * @var \Risan\OAuth1\Credentials\CredentialsFactoryInterface
30
     */
31
    protected $credentialsFactory;
32
33
    /**
34
     * Create a new OAuth1 instance.
35
     *
36
     * @param \Risan\OAuth1\HttpClientInterface $httpClient
37
     * @param \Risan\OAuth1\Request\RequestFactoryInterface $request
0 ignored issues
show
Documentation introduced by
There is no parameter named $request. Did you maybe mean $requestFactory?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
38
     * @param \Risan\OAuth1\Credentials\CredentialsFactoryInterface $credentialsFactory
39
     */
40 6
    public function __construct(HttpClientInterface $httpClient, RequestFactoryInterface $requestFactory, CredentialsFactoryInterface $credentialsFactory)
41
    {
42 6
        $this->httpClient = $httpClient;
43 6
        $this->requestFactory = $requestFactory;
44 6
        $this->credentialsFactory = $credentialsFactory;
45 6
    }
46
47
    /**
48
     * {@inheritDoc}
49
     */
50 1
    public function getHttpClient()
51
    {
52 1
        return $this->httpClient;
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     */
58 1
    public function getRequestFactory()
59
    {
60 1
        return $this->requestFactory;
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66 1
    public function getCredentialsFactory()
67
    {
68 1
        return $this->credentialsFactory;
69
    }
70
71
    /**
72
     * {@inheritDoc}
73
     */
74 1
    public function getTemporaryCredentials()
75
    {
76 1
        $response = $this->httpClient->send($this->requestFactory->createForTemporaryCredentials());
77
78 1
        return $this->credentialsFactory->createTemporaryCredentialsFromResponse($response);
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84 1
    public function buildAuthorizationUri(TemporaryCredentials $temporaryCredentials)
85
    {
86 1
        return (string) $this->requestFactory->buildAuthorizationUri($temporaryCredentials);
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     */
92
    public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verificationCode)
93
    {
94
        if ($temporaryCredentials->getIdentifier() !== $temporaryIdentifier) {
95
            throw new InvalidArgumentException('The given temporary identifier does not match the temporary credentials.');
96
        }
97
98
        $response = $this->httpClient->send(
99
            $this->requestFactory->createForTemporaryCredentials($temporaryCredentials, $verificationCode)
0 ignored issues
show
Unused Code introduced by
The call to RequestFactoryInterface:...rTemporaryCredentials() has too many arguments starting with $temporaryCredentials.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
100
        );
101
102
        return $response;
103
    }
104
}
105