Test Failed
Push — master ( 09a5f1...c566a2 )
by Alexander
12:51
created

RepositoryProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 2
b 0
f 0
dl 0
loc 15
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;
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