Passed
Pull Request — master (#405)
by Kirill
06:27
created

AttributesBootloader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 10
c 3
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 16 3
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\Cache\CacheItemInterface;
15
use Psr\SimpleCache\CacheInterface;
16
use Spiral\Attributes\Factory;
0 ignored issues
show
Bug introduced by
The type Spiral\Attributes\Factory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Spiral\Attributes\ReaderInterface;
0 ignored issues
show
Bug introduced by
The type Spiral\Attributes\ReaderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Spiral\Boot\Bootloader\Bootloader;
19
use Spiral\Core\Container;
20
21
class AttributesBootloader extends Bootloader
22
{
23
    /**
24
     * @param Container $container
25
     */
26
    public function boot(Container $container): void
27
    {
28
        $container->bindSingleton(ReaderInterface::class, function () use ($container) {
29
            $factory = new Factory();
30
31
            if ($container->has(CacheInterface::class)) {
32
                $factory = $factory->withCache(
33
                    $container->get(CacheInterface::class)
34
                );
35
            } elseif ($container->has(CacheItemInterface::class)) {
36
                $factory = $factory->withCache(
37
                    $container->get(CacheItemInterface::class)
38
                );
39
            }
40
41
            return $factory->create();
42
        });
43
    }
44
}
45