Passed
Push — main ( 9c59f2...5fac80 )
by Peter
02:52
created

CasbinCombinedAdapterBootstrapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBindings() 0 4 1
A registerBindings() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Bootstrappers\Vendor;
6
7
use AbterPhp\Framework\Authorization\CacheManager;
8
use AbterPhp\Framework\Authorization\CombinedAdapter;
9
use CasbinAdapter\Database\Adapter;
10
use Opulence\Ioc\Bootstrappers\Bootstrapper;
11
use Opulence\Ioc\Bootstrappers\ILazyBootstrapper;
12
use Opulence\Ioc\IContainer;
13
14
class CasbinCombinedAdapterBootstrapper extends Bootstrapper implements ILazyBootstrapper
15
{
16
    /**
17
     * @return array
18
     */
19
    public function getBindings(): array
20
    {
21
        return [
22
            CombinedAdapter::class,
23
        ];
24
    }
25
26
    /**
27
     * @param IContainer $container
28
     */
29
    public function registerBindings(IContainer $container)
30
    {
31
        $cacheManager    = $container->resolve(CacheManager::class);
32
        $databaseAdapter = $container->resolve(Adapter::class);
33
34
        $combinedAdapter = new CombinedAdapter($databaseAdapter, $cacheManager);
35
36
        $container->bindInstance(CombinedAdapter::class, $combinedAdapter);
37
    }
38
}
39