Completed
Push — master ( aa4cd3...2b0512 )
by yoshihiro
01:23
created

FirebaseAuthenticationModule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 7
dl 0
loc 31
c 0
b 0
f 0
ccs 17
cts 17
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Piotzkhider\FirebaseAuthenticationModule;
6
7
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Authenticate;
8
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Extractors;
9
use Piotzkhider\FirebaseAuthenticationModule\Guard\Authenticator;
10
use Piotzkhider\FirebaseAuthenticationModule\Guard\AuthenticatorInterface;
11
use Piotzkhider\FirebaseAuthenticationModule\IDTokenExtractor\AuthorizationHeaderIDTokenExtractor;
12
use Piotzkhider\FirebaseAuthenticationModule\IDTokenExtractor\IDTokenExtractorResolver;
13
use Piotzkhider\FirebaseAuthenticationModule\Interceptor\AuthenticationInterceptor;
14
use Piotzkhider\FirebaseModule\FirebaseModule;
15
use Ray\AuraWebModule\AuraWebModule;
16
use Ray\Di\AbstractModule;
17
use Ray\Di\AssistedModule;
18
use Ray\Di\Scope;
19
20
class FirebaseAuthenticationModule extends AbstractModule
21
{
22
    /**
23
     * @var mixed
24
     */
25
    private $credentials;
26
27 6
    public function __construct($credentials, AbstractModule $module = null)
28
    {
29 6
        $this->credentials = $credentials;
30 6
        parent::__construct($module);
0 ignored issues
show
Bug introduced by
It seems like $module defined by parameter $module on line 27 can also be of type object<Ray\Di\AbstractModule>; however, Ray\Di\AbstractModule::__construct() does only seem to accept null|object<self>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
31 6
    }
32
33 6
    protected function configure(): void
34
    {
35 6
        $this->install(new AssistedModule());
0 ignored issues
show
Documentation introduced by
new \Ray\Di\AssistedModule() is of type object<Ray\Di\AssistedModule>, but the function expects a object<self>.

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...
36 6
        $this->install(new AuraWebModule());
0 ignored issues
show
Documentation introduced by
new \Ray\AuraWebModule\AuraWebModule() is of type object<Ray\AuraWebModule\AuraWebModule>, but the function expects a object<self>.

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 6
        $this->install(new FirebaseModule($this->credentials));
0 ignored issues
show
Documentation introduced by
new \Piotzkhider\Firebas...ule($this->credentials) is of type object<Piotzkhider\FirebaseModule\FirebaseModule>, but the function expects a object<self>.

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
39 6
        $this->bind()->annotatedWith(Extractors::class)->toInstance([
40 6
            new AuthorizationHeaderIDTokenExtractor(),
41
        ]);
42 6
        $this->bind(IDTokenExtractorResolver::class)->in(Scope::SINGLETON);
43 6
        $this->bind(AuthenticatorInterface::class)->to(Authenticator::class)->in(Scope::SINGLETON);
44 6
        $this->bindInterceptor(
45 6
            $this->matcher->any(),
46 6
            $this->matcher->annotatedWith(Authenticate::class),
47 6
            [AuthenticationInterceptor::class]
48
        );
49 6
    }
50
}
51