Completed
Push — master ( 902192...ba7f88 )
by Risan Bagja
02:36
created

AuthorizationFlow::authorizeUrl()   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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace OAuth1\Flows;
4
5
use OAuth1\Contracts\Tokens\RequestTokenInterface;
6
7
trait AuthorizationFlow
8
{
9
    /**
10
     * Authorize url.
11
     *
12
     * @return string
13
     */
14 2
    public function authorizeUrl()
15
    {
16 2
        return $this->config()->authorizeUrl();
17
    }
18
19
    /**
20
     * Request authorization.
21
     *
22
     * @codeCoverageIgnore
23
     *
24
     * @param \OAuth1\Contracts\Tokens\RequestTokenInterface $requestToken
25
     */
26
    public function authorize(RequestTokenInterface $requestToken)
27
    {
28
        header('Location: '.$this->buildAuthorizationUrl($requestToken));
29
30
        exit();
0 ignored issues
show
Coding Style Compatibility introduced by
The method authorize() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
31
    }
32
33
    /**
34
     * Build authorization url.
35
     *
36
     * @param \OAuth1\Contracts\Tokens\RequestTokenInterface $requestToken
37
     *
38
     * @return string
39
     */
40 1
    public function buildAuthorizationUrl(RequestTokenInterface $requestToken)
41
    {
42 1
        $query = http_build_query([
43 1
            'oauth_token' => $requestToken->key(),
44 1
        ]);
45
46 1
        return $this->authorizeUrl().'?'.$query;
47
    }
48
49
    /**
50
     * Get client configuration.
51
     *
52
     * @return \OAuth1\Contracts\ConfigInterface
53
     */
54
    abstract public function config();
55
}
56