Passed
Push — master ( 1d7587...a5dfb5 )
by Gabriel
02:49
created

AuthorizationServerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 52.94%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 16
c 1
b 0
f 1
dl 0
loc 32
ccs 9
cts 17
cp 0.5294
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createAuthorizationServer() 0 11 1
A registerAuthorizationServer() 0 10 1
1
<?php
2
3
namespace ByTIC\Hello\Oauth\ServiceProvider\Traits;
4
5
use ByTIC\Hello\Utility\ModelsHelper;
6
use League\OAuth2\Server\AuthorizationServer;
7
8
/**
9
 * Trait AuthorizationServerTrait
10
 * @package ByTIC\Hello\Oauth\ServiceProvider\Traits
11
 */
12
trait AuthorizationServerTrait
13
{
14
    use GrantsTrait;
15
    use CryptKeysTrait;
16
17 2
    public function registerAuthorizationServer()
18
    {
19 2
        $this->registerCryptKeys();
20
21 2
        $this->getContainer()->alias('hello.server', AuthorizationServer::class);
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        $this->/** @scrutinizer ignore-call */ 
22
               getContainer()->alias('hello.server', AuthorizationServer::class);
Loading history...
22
23 2
        $this->getContainer()->share('hello.server', function () {
24 2
            $server = $this->createAuthorizationServer();
25 2
            $this->registerGrants($server);
26 2
            return $server;
27 2
        });
28 2
    }
29
30
    /**
31
     * @return AuthorizationServer
32
     */
33
    protected function createAuthorizationServer()
34
    {
35
        $server = new AuthorizationServer(
36
            ModelsHelper::clients(),
0 ignored issues
show
Bug introduced by
ByTIC\Hello\Utility\ModelsHelper::clients() of type Nip\Records\AbstractModels\RecordManager is incompatible with the type League\OAuth2\Server\Rep...ientRepositoryInterface expected by parameter $clientRepository of League\OAuth2\Server\Aut...onServer::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
            /** @scrutinizer ignore-type */ ModelsHelper::clients(),
Loading history...
37
            ModelsHelper::accessTokens(),
0 ignored issues
show
Bug introduced by
ByTIC\Hello\Utility\ModelsHelper::accessTokens() of type Nip\Records\AbstractModels\RecordManager is incompatible with the type League\OAuth2\Server\Rep...okenRepositoryInterface expected by parameter $accessTokenRepository of League\OAuth2\Server\Aut...onServer::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
            /** @scrutinizer ignore-type */ ModelsHelper::accessTokens(),
Loading history...
38
            ModelsHelper::scopes(),
0 ignored issues
show
Bug introduced by
ByTIC\Hello\Utility\ModelsHelper::scopes() of type Nip\Records\AbstractModels\RecordManager is incompatible with the type League\OAuth2\Server\Rep...copeRepositoryInterface expected by parameter $scopeRepository of League\OAuth2\Server\Aut...onServer::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
            /** @scrutinizer ignore-type */ ModelsHelper::scopes(),
Loading history...
39
            $this->getContainer()->get('hello.keys.private'),
40
            $this->getContainer()->get('hello.keys.public')
41
        );
42
43
        return $server;
44
    }
45
}
46