Passed
Push — master ( 1d30f9...202808 )
by Peter
04:48
created

ResourceServerBootstrapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBindings() 0 3 1
A registerBindings() 0 19 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Admin\Bootstrappers\Oauth2;
6
7
use AbterPhp\Admin\Oauth2\Repository;
8
use AbterPhp\Framework\Constant\Env;
9
use League\OAuth2\Server\ResourceServer;
0 ignored issues
show
Bug introduced by
The type League\OAuth2\Server\ResourceServer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Opulence\Databases\ConnectionPools\ConnectionPool;
11
use Opulence\Ioc\Bootstrappers\Bootstrapper;
12
use Opulence\Ioc\Bootstrappers\ILazyBootstrapper;
13
use Opulence\Ioc\IContainer;
14
use Opulence\Orm\Ids\Generators\UuidV4Generator;
15
16
class ResourceServerBootstrapper extends Bootstrapper implements ILazyBootstrapper
17
{
18
    /**
19
     * @inheritdoc
20
     */
21
    public function getBindings(): array
22
    {
23
        return [ResourceServer::class];
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function registerBindings(IContainer $container)
30
    {
31
        /** @var UuidV4Generator $uuidGenerator */
32
        $uuidGenerator = $container->resolve(UuidV4Generator::class);
33
34
        /** @var ConnectionPool $connectionPool */
35
        $connectionPool = $container->resolve(ConnectionPool::class);
36
37
        // Init our repositories
38
        $accessTokenRepository = new Repository\AccessToken($uuidGenerator, $connectionPool);
39
40
        $publicKeyPath = getenv(Env::OAUTH2_PUBLIC_KEY_PATH);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Framework\Const...:OAUTH2_PUBLIC_KEY_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
41
42
        $server = new ResourceServer(
43
            $accessTokenRepository,
44
            $publicKeyPath
45
        );
46
47
        $container->bindInstance(ResourceServer::class, $server);
48
    }
49
}
50