ClientAuthenticator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isClientValid() 0 11 2
1
<?php
2
/**
3
 * @author Boris Guéry <[email protected]>
4
 */
5
6
namespace Bgy\OAuth2;
7
8
use Bgy\OAuth2\Storage\ClientNotFound;
9
use Bgy\OAuth2\Storage\ClientStorage;
10
11
class ClientAuthenticator
12
{
13
    private $clientStorage;
14
15
    public function __construct(ClientStorage $storage)
16
    {
17
        $this->clientStorage = $storage;
18
    }
19
20
    public function isClientValid($clientId, $clientSecret)
21
    {
22
        try {
23
            $client = $this->clientStorage->findById($clientId);
24
        } catch (ClientNotFound $e) {
25
26
            return false;
27
        }
28
29
        return ((string) $client->getSecret() === (string) $clientSecret);
30
    }
31
}
32