Failed Conditions
Push — master ( 8d4434...bd8ce1 )
by Florent
04:25
created

ClientIdChecker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 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\Bundle\Server\Annotation\Checker;
15
16
use OAuth2Framework\Bundle\Server\Annotation\OAuth2;
17
use OAuth2Framework\Bundle\Server\Security\Authentication\Token\OAuth2Token;
18
19
final class ClientIdChecker implements CheckerInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function check(OAuth2Token $token, OAuth2 $configuration): ?string
25
    {
26
        if (null === $configuration->getClientId()) {
27
            return null;
28
        }
29
30
        if ($configuration->getClientId() !== $token->getClientId()) {
31
            return 'Client not authorized.';
32
        }
33
34
        return null;
35
    }
36
}
37