Passed
Pull Request — master (#1298)
by
unknown
48:10 queued 13:01
created

AbstractAuthorizeGrant::makeRedirectUri()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 3
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Abstract authorization grant.
5
 *
6
 * @author      Julián Gutiérrez <[email protected]>
7
 * @copyright   Copyright (c) Alex Bilbie
8
 * @license     http://mit-license.org/
9
 *
10
 * @link        https://github.com/thephpleague/oauth2-server
11
 */
12
13
declare(strict_types=1);
14
15
namespace League\OAuth2\Server\Grant;
16
17
use League\OAuth2\Server\Entities\ClientEntityInterface;
18
use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
19
use League\OAuth2\Server\RequestTypes\AuthorizationRequestInterface;
20
21
use function http_build_query;
22
23
abstract class AbstractAuthorizeGrant extends AbstractGrant
24
{
25
    /**
26
     * @param array<array-key,mixed> $params
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key,mixed> at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key,mixed>.
Loading history...
27 8
     */
28
    public function makeRedirectUri(string $uri, array $params = [], string $queryDelimiter = '?'): string
29 8
    {
30
        $uri .= str_contains($uri, $queryDelimiter) ? '&' : $queryDelimiter;
31 8
32
        return $uri . http_build_query($params);
33
    }
34 9
35
    protected function createAuthorizationRequest(): AuthorizationRequestInterface
36 9
    {
37
        return new AuthorizationRequest();
38
    }
39
40
    /**
41
     * Get the client redirect URI.
42
     */
43
    protected function getClientRedirectUri(ClientEntityInterface $client): string
44
    {
45
        return is_array($client->getRedirectUri())
46
            ? $client->getRedirectUri()[0]
47
            : $client->getRedirectUri();
48
    }
49
}
50