Passed
Pull Request — master (#389)
by Valentin
04:47
created

CoreBootloader::configManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 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\Boot\Bootloader;
13
14
use Spiral\Boot\DirectoriesInterface;
15
use Spiral\Boot\Memory;
16
use Spiral\Boot\MemoryInterface;
17
use Spiral\Debug\Dumper;
18
use Spiral\Files\Files;
19
use Spiral\Files\FilesInterface;
20
use Spiral\Logger;
21
22
/**
23
 * Bootloads core services.
24
 */
25
final class CoreBootloader extends Bootloader
26
{
27
    protected const DEPENDENCIES = [
28
        ConfigurationBootloader::class,
29
    ];
30
31
    protected const SINGLETONS = [
32
        // core services and helpers
33
        FilesInterface::class                   => Files::class,
34
        MemoryInterface::class                  => [self::class, 'memory'],
35
36
        // debug and logging services
37
        Dumper::class                           => Dumper::class,
38
        Logger\ListenerRegistryInterface::class => Logger\ListenerRegistry::class,
39
        Logger\LogsInterface::class             => Logger\LogFactory::class,
40
    ];
41
42
    /**
43
     * @param DirectoriesInterface $directories
44
     * @param FilesInterface       $files
45
     * @return MemoryInterface
46
     */
47
    private function memory(
48
        DirectoriesInterface $directories,
49
        FilesInterface $files
50
    ): MemoryInterface {
51
        return new Memory($directories->get('cache'), $files);
52
    }
53
}
54