Passed
Push — master ( 50ea6a...50a7ab )
by Alexander
06:00 queued 02:34
created

RepositoryProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 11
    public function register(Container $container): void
26
    {
27 11
        $orm = $container->get(ORMInterface::class);
28 11
        foreach (self::REPOSITORIES as $entity => $repository) {
29 11
            $container->set($repository, $orm->getRepository($entity));
30
        }
31 11
    }
32
}
33