accountSelectionRequired()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\exceptions;
4
5
/**
6
 * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthError
7
 */
8
class Oauth2OidcServerException extends Oauth2ServerException
9
{
10
    /**
11
     * Login Required error.
12
     * @param null|string $redirectUri A HTTP URI to redirect the user back to
13
     * @return static
14
     * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthError
15
     * @since 1.0.0
16
     */
17 1
    public static function loginRequired($redirectUri = null)
18
    {
19 1
        $errorMessage = 'User login is required';
20 1
        $hint = 'User authentication is required but the "prompt" parameter is set to "none".';
21
22 1
        return new static($errorMessage, 0, 'login_required', 400, $hint, $redirectUri);
23
    }
24
25
    /**
26
     * Interaction Required error.
27
     * @param null|string $redirectUri A HTTP URI to redirect the user back to
28
     * @return static
29
     * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthError
30
     * @since 1.0.0
31
     */
32 1
    public static function interactionRequired($redirectUri = null)
33
    {
34 1
        $errorMessage = 'User interaction is required';
35 1
        $hint = 'User interaction is required but the "prompt" parameter is set to "none".';
36
37 1
        return new static($errorMessage, 0, 'interaction_required', 400, $hint, $redirectUri);
38
    }
39
40
    /**
41
     * Consent Required error.
42
     * @param null|string $redirectUri A HTTP URI to redirect the user back to
43
     * @return static
44
     * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthError
45
     * @since 1.0.0
46
     */
47 1
    public static function consentRequired($redirectUri = null)
48
    {
49 1
        $errorMessage = 'User consent is required';
50 1
        $hint = 'User consent is required but the "prompt" parameter is set to "none".';
51
52 1
        return new static($errorMessage, 0, 'consent_required', 400, $hint, $redirectUri);
53
    }
54
55
    /**
56
     * Account Selection Required error.
57
     * @param null|string $redirectUri A HTTP URI to redirect the user back to
58
     * @return static
59
     * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthError
60
     * @since 1.0.0
61
     */
62 1
    public static function accountSelectionRequired($hint = null, $redirectUri = null)
63
    {
64 1
        $errorMessage = 'User account selection is required';
65 1
        return new static($errorMessage, 0, 'account_selection_required', 400, $hint, $redirectUri);
66
    }
67
68
    /**
69
     * "request" parameter is not supported error.
70
     * @param null|string $redirectUri A HTTP URI to redirect the user back to
71
     * @return static
72
     * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthError
73
     * @since 1.0.0
74
     */
75 1
    public static function requestParameterNotSupported($redirectUri = null)
76
    {
77 1
        $errorMessage = 'The use of the "request" parameter is not supported';
78 1
        $hint = 'Try to send the request as query parameters.';
79
80 1
        return new static($errorMessage, 0, 'request_not_supported', 400, $hint, $redirectUri);
81
    }
82
83
    /**
84
     * "request_uri" parameter is not supported error.
85
     * @param null|string $redirectUri A HTTP URI to redirect the user back to
86
     * @return static
87
     * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthError
88
     * @since 1.0.0
89
     */
90 1
    public static function requestUriParameterNotSupported($redirectUri = null)
91
    {
92 1
        $errorMessage = 'The use of the "request_uri" parameter is not supported';
93 1
        $hint = 'Try to send the request as query parameters.';
94
95 1
        return new static($errorMessage, 0, 'request_uri_not_supported', 400, $hint, $redirectUri);
96
    }
97
}
98