Passed
Pull Request — master (#840)
by Maxim
12:40 queued 05:56
created

AbstractBootloadManager::bootload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Boot\BootloadManager;
6
7
use Spiral\Boot\BootloadManagerInterface;
8
use Spiral\Core\Container;
9
use Spiral\Core\ScopeInterface;
10
11
/**
12
 * Provides ability to bootload service providers.
13
 */
14
abstract class AbstractBootloadManager implements BootloadManagerInterface, Container\SingletonInterface
15
{
16 343
    public function __construct(
17
        private readonly ScopeInterface $scope,
18
        protected readonly InitializerInterface $initializer
19
    ) {
20
    }
21
22 9
    public function getClasses(): array
23
    {
24 9
        return $this->initializer->getRegistry()->getClasses();
25
    }
26
27 342
    public function bootload(array $classes, array $bootingCallbacks = [], array $bootedCallbacks = []): void
28
    {
29 342
        $this->scope->runScope(
30
            [self::class => $this],
31 342
            function () use ($classes, $bootingCallbacks, $bootedCallbacks): void {
32 342
                $this->boot($classes, $bootingCallbacks, $bootedCallbacks);
33
            }
34
        );
35
    }
36
37
    /**
38
     * Bootload all given bootloaders.
39
     *
40
     * @param array<class-string>|array<class-string, array<string,mixed>> $classes
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<class-string>|arra...g, array<string,mixed>> at position 2 could not be parsed: Unknown type name 'class-string' at position 2 in array<class-string>|array<class-string, array<string,mixed>>.
Loading history...
41
     */
42
    abstract protected function boot(array $classes, array $bootingCallbacks, array $bootedCallbacks): void;
43
}
44