Passed
Push — feature/container-factory ( 5aed48 )
by Chema
09:15
created

DependencyProvider::provideModuleDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 14
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Feature\Framework\ContainerFactory\Module;
6
7
use Gacela\Framework\AbstractDependencyProvider;
8
use Gacela\Framework\Container\Container;
9
use GacelaTest\Fixtures\StringValue;
10
11
final class DependencyProvider extends AbstractDependencyProvider
12
{
13
    public const RANDOM_STRING_VALUE = 'FACADE_NAME';
14
15
    private const RANDOM_SEED = 'RANDOM_SEED';
16
17
    public function provideModuleDependencies(Container $container): void
18
    {
19
        $container->set(
20
            self::RANDOM_SEED,
21
            $container->factory(static fn () => random_int(0, PHP_INT_MAX))
0 ignored issues
show
Bug introduced by
function(...) { /* ... */ } of type callable is incompatible with the type object expected by parameter $service of Gacela\Framework\Container\Container::factory(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
            $container->factory(/** @scrutinizer ignore-type */ static fn () => random_int(0, PHP_INT_MAX))
Loading history...
22
        );
23
24
        $container->set(
25
            self::RANDOM_STRING_VALUE,
26
            $container->factory(static function (Container $container) {
0 ignored issues
show
Bug introduced by
function(...) { /* ... */ } of type callable is incompatible with the type object expected by parameter $service of Gacela\Framework\Container\Container::factory(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
            $container->factory(/** @scrutinizer ignore-type */ static function (Container $container) {
Loading history...
27
                /** @var int $random */
28
                $random = $container->get(self::RANDOM_SEED);
29
30
                return new StringValue('str_' . $random);
31
            })
32
        );
33
    }
34
}
35