Failed Conditions
Push — master ( 349866...67c1d1 )
by Florent
10:56 queued 06:08
created

ClientIdChecker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 10 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\SecurityBundle\Annotation\Checker;
15
16
use OAuth2Framework\SecurityBundle\Annotation\OAuth2;
17
use OAuth2Framework\SecurityBundle\Security\Authentication\Token\OAuth2Token;
18
19
final class ClientIdChecker implements Checker
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function check(OAuth2Token $token, OAuth2 $configuration): void
25
    {
26
        if (null === $configuration->getClientId()) {
27
            return;
28
        }
29
30
        if ($configuration->getClientId() !== $token->getClientId()) {
31
            throw new \Exception('Client not authorized.');
32
        }
33
    }
34
}
35