Failed Conditions
Push — ng ( a2b1ac...8ea883 )
by Florent
04:25
created

PromptNoneParameterAccountChecker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 6 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Component\AuthorizationEndpoint\UserAccount;
15
16
use OAuth2Framework\Component\AuthorizationEndpoint\Authorization;
17
use OAuth2Framework\Component\AuthorizationEndpoint\Exception\CreateRedirectionException;
18
use OAuth2Framework\Component\Core\Exception\OAuth2Exception;
19
20
class PromptNoneParameterAccountChecker implements UserAccountChecker
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function check(Authorization $authorization)
26
    {
27
        if (null === $authorization->getUserAccount() && $authorization->hasPrompt('none')) {
28
            throw new CreateRedirectionException($authorization, OAuth2Exception::ERROR_LOGIN_REQUIRED, 'The resource owner is not logged in.');
29
        }
30
    }
31
}
32