Passed
Pull Request — master (#102)
by Dmitriy
02:34
created

RepositoryProvider::getExtensions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 8
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Factory;
6
7
use Closure;
8
use Cycle\ORM\ORMInterface;
9
use Psr\Container\ContainerInterface;
10
use Yiisoft\Di\CompositeContainer;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Di\CompositeContainer 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...
11
use Yiisoft\Di\Contracts\ServiceProviderInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Di\Contracts\ServiceProviderInterface 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...
12
13
/**
14
 * This provider provides factories to the container for creating Cycle entity repositories.
15
 * Repository list is compiled based on data from the database schema.
16
 */
17
final class RepositoryProvider implements ServiceProviderInterface
18
{
19
    public function getDefinitions(): array
20
    {
21
        return [];
22
    }
23
24
    /**
25
     * @return array<Closure>
26
     */
27
    public function getExtensions(): array
28
    {
29
        return [
30
            ContainerInterface::class => function (ContainerInterface $container, ContainerInterface $extended) {
31
                /** @var ORMInterface */
32
                $orm = $extended->get(ORMInterface::class);
33
                /** @psalm-suppress InaccessibleMethod */
34
                $repositoryContainer = new RepositoryContainer($orm);
35
                $compositeContainer = new CompositeContainer();
36
                $compositeContainer->attach($repositoryContainer);
37
                $compositeContainer->attach($extended);
38
39
                return $compositeContainer;
40
            },
41
        ];
42
    }
43
}
44