FirebaseAuthenticationModule::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Piotzkhider\FirebaseAuthenticationModule;
6
7
use BEAR\Resource\ResourceObject;
8
use Kreait\Firebase\Auth as FirebaseAuth;
9
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Authenticate;
10
use Piotzkhider\FirebaseAuthenticationModule\Annotation\Extractors;
11
use Piotzkhider\FirebaseAuthenticationModule\Extractor\AuthorizationHeaderTokenExtractor;
12
use Piotzkhider\FirebaseAuthenticationModule\Extractor\TokenExtractorResolver;
13
use Piotzkhider\FirebaseAuthenticationModule\Firebase\FirebaseAuthProvider;
14
use Piotzkhider\FirebaseAuthenticationModule\Guard\Authenticator;
15
use Piotzkhider\FirebaseAuthenticationModule\Guard\AuthenticatorInterface;
16
use Piotzkhider\FirebaseAuthenticationModule\Interceptor\AuthenticationInterceptor;
17
use Piotzkhider\FirebaseModule\FirebaseModule;
18
use Ray\AuraWebModule\AuraWebModule;
19
use Ray\Di\AbstractModule;
20
use Ray\Di\AssistedModule;
21
use Ray\Di\Scope;
22
23
class FirebaseAuthenticationModule extends AbstractModule
24
{
25
    /**
26
     * @var mixed
27
     */
28
    private $credentials;
29
30 2
    public function __construct($credentials, AbstractModule $module = null)
31
    {
32 2
        $this->credentials = $credentials;
33 2
        parent::__construct($module);
0 ignored issues
show
Bug introduced by
It seems like $module defined by parameter $module on line 30 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...
34 2
    }
35
36 2
    protected function configure(): void
37
    {
38 2
        $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...
39 2
        $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...
40 2
        $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...
41
42 2
        $this->bind(FirebaseAuth::class)->toProvider(FirebaseAuthProvider::class)->in(Scope::SINGLETON);
43 2
        $this->bind(AuthInterface::class)->to(Auth::class)->in(Scope::SINGLETON);
44 2
        $this->bind()->annotatedWith(Extractors::class)->toInstance([
45 2
            new AuthorizationHeaderTokenExtractor(),
46
        ]);
47 2
        $this->bind(TokenExtractorResolver::class)->in(Scope::SINGLETON);
48 2
        $this->bind(AuthenticatorInterface::class)->to(Authenticator::class)->in(Scope::SINGLETON);
49 2
        $this->bindInterceptor(
50 2
            $this->matcher->subclassesOf(ResourceObject::class),
51 2
            $this->matcher->annotatedWith(Authenticate::class),
52 2
            [AuthenticationInterceptor::class]
53
        );
54 2
    }
55
}
56