Passed
Push — master ( dca89f...91c2eb )
by Anton
02:26
created

JobsBootloader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jobRegistry() 0 3 1
A boot() 0 3 1
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\Jobs;
13
14
use Psr\Container\ContainerInterface;
15
use Spiral\Boot\Bootloader\Bootloader;
16
use Spiral\Boot\KernelInterface;
17
use Spiral\Bootloader\ServerBootloader;
18
use Spiral\Jobs\HandlerRegistryInterface;
19
use Spiral\Jobs\JobDispatcher;
20
use Spiral\Jobs\JobQueue;
21
use Spiral\Jobs\JobRegistry;
22
use Spiral\Jobs\QueueInterface;
23
use Spiral\Jobs\Registry\ContainerRegistry;
24
use Spiral\Jobs\SerializerRegistryInterface;
25
26
final class JobsBootloader extends Bootloader
27
{
28
    protected const DEPENDENCIES = [
29
        ServerBootloader::class
30
    ];
31
32
    protected const SINGLETONS = [
33
        QueueInterface::class              => JobQueue::class,
34
        HandlerRegistryInterface::class    => JobRegistry::class,
35
        SerializerRegistryInterface::class => JobRegistry::class,
36
        JobRegistry::class                 => [self::class, 'jobRegistry']
37
    ];
38
39
    /**
40
     * @param KernelInterface $kernel
41
     * @param JobDispatcher $jobs
42
     */
43
    public function boot(KernelInterface $kernel, JobDispatcher $jobs): void
44
    {
45
        $kernel->addDispatcher($jobs);
46
    }
47
48
    /**
49
     * @param ContainerInterface $container
50
     * @param ContainerRegistry $registry
51
     * @return JobRegistry
52
     */
53
    private function jobRegistry(ContainerInterface $container, ContainerRegistry $registry)
54
    {
55
        return new JobRegistry($container, $registry, $registry);
56
    }
57
}
58