Passed
Push — master ( abc2ba...40955b )
by Anton
02:23
created

DomainBootloader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A domainCore() 0 9 2
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Bootloader;
13
14
use Psr\Container\ContainerInterface;
15
use Spiral\Boot\Bootloader\Bootloader;
16
use Spiral\Core\Core;
17
use Spiral\Core\CoreInterface;
18
use Spiral\Core\InterceptableCore;
19
20
/**
21
 * Configures global domain core (CoreInterface) with the set of interceptors to alter domain layer functionality.
22
 */
23
abstract class DomainBootloader extends Bootloader
24
{
25
    protected const SINGLETONS = [
26
        CoreInterface::class => [self::class, 'domainCore']
27
    ];
28
29
    // the set of interceptors for the domain code
30
    protected const INTERCEPTORS = [];
31
32
    /**
33
     * @param Core               $core
34
     * @param ContainerInterface $container
35
     * @return InterceptableCore
36
     */
37
    protected function domainCore(Core $core, ContainerInterface $container)
38
    {
39
        $core = new InterceptableCore($core);
40
41
        foreach (static::INTERCEPTORS as $interceptor) {
42
            $core->addInterceptor($container->get($interceptor));
43
        }
44
45
        return $core;
46
    }
47
}
48