Passed
Pull Request — master (#89)
by Dmitriy
34:28 queued 08:00
created

RepositoryProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 4
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 5 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Provider;
6
7
use App\Blog\Post;
8
use App\Blog\PostRepository;
9
use App\User\User;
10
use App\User\UserRepository;
11
use Cycle\ORM\ORMInterface;
12
use Yiisoft\Di\Container;
13
use Yiisoft\Di\Support\ServiceProvider;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Di\Support\ServiceProvider 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...
14
15
final class RepositoryProvider extends ServiceProvider
16
{
17
    private const REPOSITORIES = [
18
        User::class => UserRepository::class,
19
        Post::class => PostRepository::class,
20
    ];
21
22
    /**
23
     * @psalm-suppress InaccessibleMethod
24
     */
25
    public function register(Container $container): void
26
    {
27
        $orm = $container->get(ORMInterface::class);
28
        foreach (self::REPOSITORIES as $entity => $repository) {
29
            $container->set($repository, $orm->getRepository($entity));
30
        }
31
    }
32
}
33