Test Failed
Push — master ( a6b51e...5fffdb )
by Gabriel
08:05
created

AuthorizationServerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 16
cts 16
cp 1
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerAuthorizationServer() 0 12 1
A createAuthorizationServer() 0 12 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?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
22
23
        $this->getContainer()->share('hello.server', function () {
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?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
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 2
    protected function createAuthorizationServer()
34
    {
35 2
        $server = new AuthorizationServer(
36 2
            ModelsHelper::clients(),
0 ignored issues
show
Documentation introduced by
\ByTIC\Hello\Utility\ModelsHelper::clients() is of type object<Nip\Records\AbstractModels\RecordManager>, but the function expects a object<League\OAuth2\Ser...entRepositoryInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37 2
            ModelsHelper::accessTokens(),
0 ignored issues
show
Documentation introduced by
\ByTIC\Hello\Utility\ModelsHelper::accessTokens() is of type object<Nip\Records\AbstractModels\RecordManager>, but the function expects a object<League\OAuth2\Ser...kenRepositoryInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38 2
            ModelsHelper::scopes(),
0 ignored issues
show
Documentation introduced by
\ByTIC\Hello\Utility\ModelsHelper::scopes() is of type object<Nip\Records\AbstractModels\RecordManager>, but the function expects a object<League\OAuth2\Ser...opeRepositoryInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39 2
            $this->getContainer()->get('hello.keys.private'),
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?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
40 2
            $this->getContainer()->get('hello.keys.public')
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?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
41
        );
42
43 2
        return $server;
44
    }
45
}
46